nignx配置同域名下多個項目

同一個域名下配置多個項目html

原來的ngnix基本配置:tomcat

server
        {
                listen 80;
                server_name b.test.com;
                access_log off;
                include filter.conf;

	
                location ~* ^.+\.(action|do|jsp|ftl|sc) {
                        proxy_pass http://testtomcat;
                        include proxy.conf;
                }
                location / {
                        rewrite  ^/m/([0-9]+)/$  test/lalMIndex.do?pi=$1 last;
                        root  D:\WWZ-Company\Fccszt\workspace\test\WebRoot;
                }
        }

這是b項目的配置 須要把帶/line/live/的請求代理帶a項目配置以下:jsp

location ~* ^/line/live/ {
			proxy_pass http://127.0.0.1;        #a的ip
			include proxy_live.conf;
	}

proxy_live.conf中配置a的域名:spa

set $new_host           a.test.com;

這樣,請求 b.test.com/line/live/xxx.html 就會顯示a項目中對應程序.代理

proxy.confcode

proxy_redirect          off;
     proxy_set_header        Host $host;    #a的把該位置替換爲
     #set $new_host           a.test.com;
     #proxy_set_header        Host $new_host;
     proxy_set_header        X-Real-IP $remote_addr;
     proxy_set_header        X-Forwarded-For   $proxy_add_x_forwarded_for;
     client_max_body_size    10m;
     client_body_buffer_size 128k;
     proxy_connect_timeout   90;
     proxy_send_timeout      90;
     proxy_read_timeout      90;
     proxy_buffer_size       4k;
     proxy_buffers           4 32k;
     proxy_busy_buffers_size 64k;
     proxy_temp_file_write_size 64k;
相關文章
相關標籤/搜索