我有一个旧的服务器设置,我给人们提供了端口 420 的服务的 URL,example.corp.com:420,现在我将所有服务移动到 Ngnix 中的常规 80 端口,我希望所有请求都来自示例。 corp.com:420 改为默认返回 example.corp.com。有没有办法告诉 Ngnix 去 app1 而不管给定的端口号是什么?我尝试了几件事,但都没有奏效。这是我目前的配置。提前致谢。
upstream unicorn-app1 {
server unix:/tmp/unicorn.app1.sock;
}
server {
listen 80;
server_name example.corp.com;
root /home/example/apps/wm/current/public;
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_redirect off;
if (!-f $request_filename) {
proxy_pass http://unicorn-app1;
break;
}
}
}
upstream unicorn-app2{
server unix:/tmp/unicorn.app2.sock;
}
server {
listen 420;
server_name example.corp.com;
root /home/example/apps/app2/current/public;
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_redirect off;
if (!-f $request_filename) {
proxy_pass http://unicorn-app2;
break;
}
}
}