nginx反向代理配置域名映射

在Nginx.conf里面

server {
     
	# 监听 80 端口
    listen 80;
    autoindex on;
    server_name www.baidu.com;
    #access_log /usr/local/nginx/logs/access.log combined;
    index doc.html ;
    if ( $query_string ~* ".*[\;'\<\>].*" ){
     
        return 404;
    }
    location / {
     
        # 反向代理到 9999 端口
        proxy_pass http://111.111.111.111:9999;
        proxy_set_header    REMOTE-HOST $remote_addr;
        proxy_set_header   Host $host;
        proxy_set_header   X-Real-IP $remote_addr;
        proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}

或者 本机9999转80

server {
     
	# 监听 8080 端口
    listen *:80;
    autoindex on;
   # server_name www.baidu.com;
    #access_log /usr/local/nginx/logs/access.log combined;
    index doc.html ;
    if ( $query_string ~* ".*[\;'\<\>].*" ){
     
        return 404;
    }
    location / {
     
        # 反向代理到 9999 端口
        proxy_pass http://111.111.111.111:9999;
        proxy_set_header    REMOTE-HOST $remote_addr;
        proxy_set_header   Host $host;
        proxy_set_header   X-Real-IP $remote_addr;
        proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}

你可能感兴趣的:(软件)