Nginx反向代理

  1. 打开/usr/local/nginx/conf/nginx.conf
vi /usr/local/nginx/conf/nginx.conf

upstream test1 {  
        server 192.168.0.190:8080;
    }
upstream jenkins_t1 {
        server 192.168.0.190:8088;
    }
server {  
            listen       80;  
            server_name  test.tieli.com;  
      
            #charset koi8-r;  
      
            #access_log  logs/host.access.log  main;  
      
            location / {
                proxy_set_header Host $Host;
                proxy_pass   http://test1;  
                index  index.html index.htm;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header X-Forwarded-Port $Server_port;
                proxy_set_header X-Forwarded-Proto $scheme;
                
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "upgrade";
            }
        }
server {  
            listen       80;  
            server_name  jenkins.tieli.com;  
      
            #charset koi8-r;  
      
            #access_log  logs/host.access.log  main;  
      
            location / {  
                proxy_pass   http://jenkins_t1;  
                index  index.html index.htm;
            }
        }
    
map $http_upgrade $connection_upgrade {
            default upgrade;
             ''      close;
  }
  1. 重启Nginx
./sbin/nginx -s reload
  1. 防火墙设置
#查看打开的端口
firewall-cmd --zone=public --list-ports
#禁用端口
firewall-cmd --zone=public --remove-port=8080/tcp --permanent
firewall-cmd --zone=public --remove-port=8088/tcp --permanent
# 更新防火墙
firewall-cmd --reload

你可能感兴趣的:(Nginx反向代理)