簡體   English   中英

Nginx Node.js在Windows中的同一端口上

[英]Nginx nodejs on same port in windows

如何在Windows上使用Node.js運行Nginx已經回答了這個問題 但是,以下操作似乎無效。 然后我去了http://nginx.org/en/docs/windows.html ,它沒有太大幫助。 這是我的問題的簡要說明。

jxcore在http:// localhost:3434 /上運行,並成功提供了測試文件hello.js

端口80上的Nginx正常工作。

因此,要使其重定向,請遵循上面的url,下面是當前的配置。

server {
    listen       80;
    server_name  localhost;

    access_log D:\nginx-1.10.1\logs\access.log;
            location ~ ^/(javascripts|stylesheets|images) {
            expires max;

    location / {
        root   html;
        index  index.html index.htm; #i tried adding hello.js here as well but didn't work
    }

    location /pubsub { #node js files are in a sub directory under nginx root
        proxy_pass http://localhost:3434;
    }
}

我重新啟動nginx並轉到localhost后,它將提供靜態文件。 但是當我進入localhost / pubsub時,它給出了403 Forbidden。 它說到權限問題,但是在Windows中配置nginx時,沒有地方說您需要像* nix安裝中那樣插入權限?

好! 這是無意中解決的! :)

最初,我的重定向如下。 這個想法是,如果有人去localhost / pubsub,它應該重定向到nodejs,這是行不通的。 它顯示了403

location /pubsub { #node js files are in a sub directory under nginx root
    proxy_pass http://localhost:3434;
}

工作配置為;

location /pubsub/ { # notice the trailing slash
    proxy_pass http://localhost:3434;
}

我也將默認的.js文件添加到Index參數。

僅此而已 ,現在http:// localhost / pubsub進入了節點!

暫無
暫無

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

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