nginx监听一个端口多域名转发配置

#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


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;
    #用服务器IP不能访问
     server {
        listen       80;
        server_name 182.92.xx.xx;
        error_page 404 401 400  /400.html;

        location / {             
            root   html;
            index 400.html;        
        }
    
        location = /40x.html{
            root html;
        }
    }
    
    server {
        listen       80;
        server_name  xxx1.com.cn www.xxx1.com.cn;
 
        location / {
            proxy_pass  http://localhost:8091;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            root   html;
            index  index.html index.htm;
        }
    }
    server {
        listen       80;
        server_name  xxx2.com www.xxx2.com;
 
        location / {
            proxy_pass  http://localhost:7080;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            root   html;
            index  index.html index.htm;
        }
    }

 

}

你可能感兴趣的:(java,web开发)