nginx 代理http配置实例

#user  nginx;
worker_processes  5;

#error_log  /var/log/nginx/error.log warn;
#pid        /var/run/nginx.pid;


events {
    worker_connections  10240;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

   upstream Jq_one{
    #server 192.168.11.175:8090;
    #server 192.168.11.192:8090;
    server  zh.hainan.gov.cn;
    #server  10.34.1.31;
    }

    server {
        listen       90;
        server_name  10.34.1.21;
     
        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        #location / {
        #    root   html;
        #    index  index.html index.htm;
        #}
    #my own location
    location / {
        proxy_pass         http://Jq_one; 
        #proxy_pass http://localhost;
        #proxy_redirect / /ahyc/Web_Water/;
     #proxy_redirect default;
     root   html;
        index  index.aspx index.html index.htm; #修改主页为index.aspx
     #其中jq_one 对应着upstream设置的集群名称
     
     #设置主机头和客户端真实地址,以便服务器获取客户端真实IP
     proxy_set_header   Host             $host; 
     proxy_set_header   X-Real-IP        $remote_addr; 
     proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;

}}

#第二个port app test;
upstream ahwater_portal{
server 10.34.1.31;
}
server {
        listen       91;
        server_name  10.34.1.21;
    location / {
        proxy_pass         http://ahwater_portal; 
     root   html;
        index  index.aspx index.html index.htm; #修改主页为index.aspx
     #其中jq_one 对应着upstream设置的集群名称
     
     #设置主机头和客户端真实地址,以便服务器获取客户端真实IP
     proxy_set_header   Host             $host; 
     proxy_set_header   X-Real-IP        $remote_addr; 
     proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;

}}
#第二个port app test;
upstream ahwater_portal2{
server 10.2.1.221;
}
server {
        listen       92;
        server_name  10.34.1.21;
    location /{
       proxy_pass   http://ahwater_portal2; 
       root        html;
       index  index.aspx index.html index.htm; #修改主页为index.aspx
        
     #其中jq_one 对应着upstream设置的集群名称
     
     #设置主机头和客户端真实地址,以便服务器获取客户端真实IP
     proxy_set_header   Host             $host; 
     proxy_set_header   X-Real-IP        $remote_addr; 
     proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;

       } 

}




}

 

上一篇:Android Fragments 详细使用


下一篇:九爷带你了解 nginx HTTP模块配置常用指令