監聽80端口 轉發多端口

  • 以域名 www.xxx.com爲例子

監聽80端口 將 test1.xxx.com 轉發到8080端口
監聽80端口 將 test2.xxx.com 轉發到8070端口
監聽80端口 將 www.xxx.com 轉發到本地靜態html路徑

user  root;
worker_processes  2;
events {
    worker_connections  1024;
}
http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;

    # 將 test1.xxx.com 轉發到8080端口
    upstream test1.xxx.com {
            server 127.0.0.1:8080;
    }
    #監聽80端口  將 test1.xxx.com 轉發到本地8080端口
    server { 
        listen       80;
        server_name  test1.xxx.com;
        client_max_body_size 1000M;
        location / {
            proxy_pass http://test1.xxx.com;
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
    #監聽80端口  將 test2.xxx.com 轉發到8070端口
    server {
        listen       80;
        server_name  test2.xxx.com;
        client_max_body_size 1000M;
        location /{
                proxy_pass http://ip: 8070;
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
    # 監聽80端口 將 www.xxx.com 轉發到本地靜態html
    server {
        listen       80;
        server_name  www.xxx.com;
        client_max_body_size 1000M;
        location /{
            alias /usr/local/web/html/officialWebsite/;
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
    # 監聽8888端口 這是FastDFS  轉發到ngx_fastdfs_module
    server {
        listen       8888;
        server_name  ip;
        location ~/group[0-9]/ {
                ngx_fastdfs_module;
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
        root   html;
        }
    }
}

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章