我有两个nginx
服务器实例,一个运行corporate ip
,另一个运行internal ip
.I,希望从外部nginx获得链接,重定向到内部nginx服务器,并使用外部nginx作为网关。还需要确保在dynamic IP
上运行的内部nginx
已尝试使用动态IP的变量,如代码片段所示
location /route/(?<section>.+){
proxy_bind 172.31.*.*;
proxy_pass http://$section/single-table-view;
proxy_set_header Host $http_host;
}
发布于 2019-07-26 13:21:00
您需要对nginx进行如下配置:
如果你想将你的外部nginx重定向到内部nginx,你应该这样配置你的外部服务器:
server {
listen 80;
listen [::]:80;
server_name domain_name;
location / {
proxy_pass http://InternalNginxIpAddress:PortYouWant;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
现在,来自外部nginx的每个请求都会被转发到内部nginx,在那里您的内部nginx服务器被设置为
proxy_pass http://localhost:PortYouWant;
https://stackoverflow.com/questions/57213200
复制相似问题