nginx--配置二級域名對應多個項目(二)

上傳地本項目到服務器

不上傳node_modules文件夾,上傳項目後,再cnpm installnode

clipboard.png

nginx

配置nginx.confnginx

  1. listen寫80
  2. server_name 寫二級域名
  3. proxy_pass 寫項目的端口號
server{
        listen 80;
        server_name blog.pengyongjie.top;
        location / { 
            proxy_pass http://127.0.0.1:8001;   
           }
        }

clipboard.png

啓動操做

先中止項目和nginxnpm

npm stop
killall nginx

先啓動項目服務器

npm start

再啓動nginxurl

nginx

clipboard.png

三個url訪問同一個ip

http://119.29.93.144:8001/newsspa

  1. http://blog.pengyongjie.top/news
  2. http://pengyongjie.top:8001/news
  3. http://blog.pengyongjie.top:8001/news

另外一種配置二級域名的方法

項目二egg08,端口8002

clipboard.png

/etc/nginx/nginx.conf

前面加#註釋掉項目二的servercode

clipboard.png

clipboard.png

項目二的server配置,在nginx.conf的子配置文件中配置

端口號爲8002,因此命名8002server

server{
        listen 80;
        server_name shop.pengyongjie.top;
        location / { 
            proxy_pass http://127.0.0.1:8002;
        }
   }

shop.pengyongjie.topblog

clipboard.png

域名解析配置

在域名解析,加上二級域名ip

clipboard.png

相關文章
相關標籤/搜索