nginx多个域名解析同一ip的不同应用

一级域名:percywang.top 解析为106.12.221.34:2000这个应用
二级域名:auth.percywang.top 解析为106.12.221.34:2001这个应用

注意:一级域名server的转发配置一定要在二级域名的后面

     server{
	            listen 80;
	            server_name  auth.percywang.top;
	            index  index.php index.html index.htm;
	            location / {
	           		 proxy_pass  http://127.0.0.1:2001/;
	            }
          }
     server{
	            listen 80;
	            server_name  percywang.top;
	            index  index.php index.html index.htm;
	            location / {
	            	 proxy_pass  http://127.0.0.1:2000/;
	            }
          }
    // 应用1:
	server {
              listen 2000;
              server_name percywang.top;
		      location / {
		           root   /home/twitter-blog-vue/dist/;
	               try_files $uri $uri/ /index.html;
		     }
	       }
   // 应用2:
   server {
              listen 2001;
              server_name auth.percywang.top;
	          location / {
			           root   /home/vue-authentication/dist/;
			           try_files $uri $uri/ /index.html;
	          }
         }

 

你可能感兴趣的:(linux)