思想
nginx跳转到另一个nginx
两台服务器113和112都装有nginx,113为入口,分别配置113和112双节点静态文件
113nginx
server {
listen 80;
server_name xxxx;
access_log logs/zeq.access.log main;
error_log logs/zeq.error.log error;
#nginx配置静态文件,发送post请求会报405,将405捕获
error_page 405 =200 @405;
location @405 {
proxy_method POST;
proxy_pass http://gateway;
}
location / {
#alias /etc/nginx/admin/;
#index index.html index.htm;
#解决angular容器导致的异常
#try_files $uri $uri/ /index.html =404;
proxy_pass http://admin;
}
}
server {
listen 4201;
server_name 172.18.0.113;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
alias /usr/local/nginx/admin/;
index index.html index.htm;
try_files $uri $uri/ /index.html =404;
}
error_page 405 =200 @405;
location @405 {
proxy_method POST;
proxy_pass http://gateway;
}
}
upstream admin {
server 172.18.0.113:4201;
server 172.18.0.112:4201;
}
112nginx
server {
listen 4201;
server_name 172.18.0.112;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
alias /usr/local/nginx/admin/;
index index.html index.htm;
try_files $uri $uri/ /index.html =404;
}
error_page 405 =200 @405;
location @405 {
proxy_method POST;
proxy_pass http://gateway;
}
}
upstream gatewayt {
server 172.18.0.119:8070;
}