1.原理
Nginx解析location/后面的字符串,配置不同的字符串匹配不同的URL进行反向代理。
2.nginx.conf配置文件
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 2016;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
location /yyxtManager {
proxy_pass http://10.56.6.13:6667/yyxtManager;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location /jrtxManager {
proxy_pass http://10.56.6.13:6666/jrtxManager;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location /hytpay {
proxy_pass http://10.56.6.13:5555/hytpay;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location /wlgz {
proxy_pass http://10.56.6.13:4444/wlgz;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $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;
}
}
}