簡體   English   中英

使用NginX在Digital Ocean上托管多個node.js應用程序

[英]Host multiple node.js applications on Digital Ocean using NginX

我按照本指南為節點應用程序設置了反向代理-https: //www.digitalocean.com/community/tutorials/how-to-host-multiple-node-js-applications-on-a-single-vps-與-nginx的-永遠和-的crontab

其要點是包括此配置

server {
    listen 80;

    server_name your-domain.com;

    location / {
        proxy_pass http://localhost:3000;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }
}

這似乎適用於根目錄-/,但是在添加自定義文件夾路徑時失敗。 像這樣-

server {
    listen 80;

    server_name your-domain.com;

    location /test/ {
        proxy_pass http://localhost:3000;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }

}

我的目標是使用example.com/test/導航到我的站點,以便我可以列出程序的多個路徑。 我從chrome收到的錯誤無法獲取example.com/test/

每個應用程序proxy_pass的端口都必須不同。 您也可以參考此數字海洋文章

 server {
        listen 80;

server_name your-domain.com;

location / {
    proxy_pass http://localhost:3000;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection 'upgrade';
    proxy_set_header Host $host;
    proxy_cache_bypass $http_upgrade;
}

location /test {
    proxy_pass http://localhost:3009;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection 'upgrade';
    proxy_set_header Host $host;
    proxy_cache_bypass $http_upgrade;
}
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM