nginx - 配置 重定向 代理
nginx - 配置 重定向 代理
# "/usr/local/nginx/conf/conf.d/creditcardbankweb.conf"
server {
listen 11300;
# server_name localhost; # 部分版本不支持localhost
server_name 127.0.0.1;
#charset koi8-r;
#access_log logs/host.access.log main;
location /{
root /home/ldt/creditcard/bankweb;
# root /home/ldt/creditcard/lawweb/;
index index.html index.htm;
# add_header Access-Control-Allow-Origin *;
}
# /login 路由重定向
if ($uri ~* /login) {
# 非 /api 过滤接口请求
# rewrite ^/login http://xxx.xxx.x.xx:17777/login?systemCode=Creditcard_BankWeb permanent;
# rewrite ^/login http://xxx.xxx.x.xx:17777/login permanent;
rewrite ^/login $scheme://$host:17777/login permanent; # 127.0.0.1 指向电脑本地非服务器本地
}
# bank端代理
# http://localhost:11300/creditcard-bank/basic/homepage -> http://xxx.xxx.x.xx:11310/creditcard-bank/basic/homepage
#跳转到指点tomcat服务器
proxy_pass http://xxx.xxx.x.xx:11310/creditcard-bank/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 2000m; // 上传文件大小限制
}
# 用户中心代理
# http://localhost:11300/api/v2/login -> http://xxx.xxx.x.xx:17777/api/v2/login
location /api{
proxy_pass http://xxx.xxx.x.xx:17777/api/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
# 消息中心代理
# http://localhost:11300/msg-center/private/getMsgInfoList -> http://xxx.xxx.x.xx:10082/msg-center/private/getMsgInfoList
location /msg-center{
proxy_pass http://xxx.xxx.x.xx:10082/msg-center/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
Lee2