• Nginx反向代理新篇-使用location对多个URL做反向代理


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

      

  • 相关阅读:
    vscode中配置git
    javaScript基础-03 javascript语句
    使用DOM4J解析XML文档
    使用JDOM解析XML
    使用SAXParser解析XML文档的实例
    Schema技术的使用小结.
    Java.util.Arrays 工具类的使用
    3种类内部的用法(成员,局部,匿名)
    File类的常用方法.
    Math类的常用方法和静态导入.
  • 原文地址:https://www.cnblogs.com/jkr666666/p/7089389.html
Copyright © 2020-2023  润新知