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

相关文章
相关标签/搜索