二級域名nginx 配置

小贝馨發表於2024-03-07

訪問地址 http://二級域名稱.域名名稱.com/

server {
  listen 80;
  server_name 二級域名稱.一級域名xxxxx.com;
  location / {
    proxy_pass http://localhost:8282;
  }
}

server{
  listen 8282;
  server_name localhost;

  location / {
    root /home/ncyh_lkjp/web/dist; //前端部署地址
    try_files $uri $uri/ /index.html;
    index index.html index.html;
  }

  location /prod-api/ { // 後端服務介面字首
    proxy_set_header Host $http_host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header REMOTE-HOST $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_pass http://localhost:9080/; // 後端伺服器埠號
  }

}

相關文章