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;  
        }  
    }  
} 

  

相关文章:

  • 2022-01-28
  • 2022-12-23
  • 2021-09-02
  • 2021-09-22
  • 2018-12-22
  • 2019-05-22
猜你喜欢
  • 2022-12-23
  • 2021-12-12
  • 2022-02-11
  • 2021-06-07
  • 2021-08-29
  • 2022-01-26
  • 2022-01-05
相关资源
相似解决方案