nginx服务转发

1. 转发ip和端口

        listen       9800;
        server_name  localhost;
        #charset koi8-r;
        #access_log  logs/host.access.log  main;
        location /{
            proxy_pass http://11.55.38.60:9800;#转发请求的地址
            
            proxy_set_header HTTP_X_FORWARDED_FOR "$remote_addr:$remote_port" ;
            
            proxy_set_header Host $host:$server_port;
        
               
            proxy_connect_timeout 60s; 
            
            proxy_read_timeout 300s; 
            
            proxy_send_timeout 60s; 
        }

2. 带地址

        listen       9800;
        server_name  localhost;
        #charset koi8-r;
        #access_log  logs/host.access.log  main;
        location /pacs{
            proxy_pass http://11.55.38.60:9800/pacs;#转发请求的地址
            
            proxy_set_header HTTP_X_FORWARDED_FOR "$remote_addr:$remote_port" ;
            
            proxy_set_header Host $host:$server_port;
        
               
            proxy_connect_timeout 60s; 
            
            proxy_read_timeout 300s; 
            
            proxy_send_timeout 60s; 
        }

 

3. 转发多个分发

upstream nuc {
       server 192.168.200.154:6303;# max_fails=2 fail_timeout=10s;
       server 10.30.28.43:9003;# max_fails=2 fail_timeout=10s;
       #server 10.30.28.43:9004;# max_fails=2 fail_timeout=10s;
       #keepalive 128; --新增
    }

server {
        listen       9063;
        server_name  sc.shou.cn; #这里是域名

        #root   /data/web;
        root   html;

        location /nuc {
            root   html;
            #root   /data/web;
            try_files $uri $uri/ @router
            index  index.html index.htm;
        }
...
}

 

posted @ 2022-04-13 17:40  leolzi  阅读(2605)  评论(0编辑  收藏  举报