我正在尝试使用proxy_pass在端口80上使用Nginx公开我的Web。Web是在Node中使用Express编写的,它们都运行在不同的端口号上。
当从根目录和/test中提取静态文件时,我的位置在nginx.conf文件中工作,但在尝试重定向到/test时收到404 error。我正在测试的应用程序接口在port 8080上运行,我能够使用Postman访问和测试它。
这是使用托管在Windows 2016 Server上的Nginx 1.16.1
http {
include mime.types;
default_type application/octet-stream;
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost crowdtrades.com;
//Root and /test locations are working correctly
location / {
root c:/CrowdTrades;
index index.html index.htm;
}
location /test/ {
root c:/CrowdTrades/test;
index test.html;
}
// #Test2 this is the location I'm not able to get working
location /test2/ {
proxy_set_header Host $host;
proxy_pass http://localhost:8080/api/signup/;
}
}
}发布于 2019-10-02 00:19:41
因此,在尝试了各种配置更改并每次重启Nginx之后,我放弃了整晚。我的云虚拟机计划在晚上关闭,当我在上午拿到它的时候,它还在工作。我不知道为什么它现在能工作,但重启服务器似乎有帮助。
https://stackoverflow.com/questions/58175881
复制相似问题