首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为什么在NginX中使用proxy_pass时会收到404?

问为什么在NginX中使用proxy_pass时会收到404?
EN

Stack Overflow用户
提问于 2019-10-01 06:10:38
回答 1查看 187关注 0票数 0

我正在尝试使用proxy_pass在端口80上使用Nginx公开我的Web。Web是在Node中使用Express编写的,它们都运行在不同的端口号上。

当从根目录和/test中提取静态文件时,我的位置在nginx.conf文件中工作,但在尝试重定向到/test时收到404 error。我正在测试的应用程序接口在port 8080上运行,我能够使用Postman访问和测试它。

这是使用托管在Windows 2016 Server上的Nginx 1.16.1

代码语言:javascript
复制
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/;
    }

        }


    }
EN

回答 1

Stack Overflow用户

发布于 2019-10-02 00:19:41

因此,在尝试了各种配置更改并每次重启Nginx之后,我放弃了整晚。我的云虚拟机计划在晚上关闭,当我在上午拿到它的时候,它还在工作。我不知道为什么它现在能工作,但重启服务器似乎有帮助。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58175881

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档