Node.js Nginx“;无法获取/index.html";关于工作域的代理传递

Node.js Nginx“;无法获取/index.html";关于工作域的代理传递,node.js,nginx,amazon-elastic-beanstalk,Node.js,Nginx,Amazon Elastic Beanstalk,让我直接跳到这里:我正在尝试代理将我的基本URL(test.co)传递到另一个域(webflow.test.co)。但是,简单地说,我遇到了麻烦。到目前为止,我已经解决了很多问题,但我又被困在这里了。域(webflow.test.co)工作正常,因此没有问题。。。但是当我尝试使用代理传递(如下所示)时,我在浏览器中遇到一个错误“Cannot get/index.html” 查看一下Chrome开发工具,就会发现重定向到webflow.test.co的情况并没有发生(我认为,我对devtools的

让我直接跳到这里:我正在尝试代理将我的基本URL(test.co)传递到另一个域(webflow.test.co)。但是,简单地说,我遇到了麻烦。到目前为止,我已经解决了很多问题,但我又被困在这里了。域(webflow.test.co)工作正常,因此没有问题。。。但是当我尝试使用代理传递(如下所示)时,我在浏览器中遇到一个错误“Cannot get/index.html”

查看一下Chrome开发工具,就会发现重定向到webflow.test.co的情况并没有发生(我认为,我对devtools的这一领域并不在行),并且可能因此无法检索index.html

这是我的nginx配置文件(我正在将除主服务器以外的所有请求路由到我的NodeJS服务器):

上游节点{
服务器127.0.0.1:8081;
保持256;
}
#将所有非HTTPS重定向到非WWW HTTPS
服务器{
听8080;
服务器名称“~^(?:www\)?(.*)$”;
返回301 https://$host$request\u uri;
}
#将WWW HTTP重定向到非WWW HTTP
服务器{
听4430;
服务器名称“^www.*)$”;
返回301 https://$1$request\u uri;
}
服务器{
地点/{
代理通行证https://webflow.test.co;
代理集头连接“”;
proxy_http_版本1.1;
代理设置头主机$Host;
代理集头X-Real-IP$remote\u addr;
proxy\u set\u header X-Forwarded-For$proxy\u add\u X\u Forwarded\u For;
代理集头X转发协议https;
}
}
#反向代理http://nodejs
服务器{
听4430;
服务器名称“~^(?!www\).*$”;
客户的最大车身尺寸为50M;
位置~/(?。+){
代理通行证http://nodejs;
代理集头连接“”;
proxy_http_版本1.1;
代理设置头主机$Host;
代理集头X-Real-IP$remote\u addr;
proxy\u set\u header X-Forwarded-For$proxy\u add\u X\u Forwarded\u For;
}
}
非常非常感谢您的帮助。我会接受第一个有效且明智的答案。非常感谢


编辑1:我刚刚测试时根本没有使用SSL,响应是相同的-无法获取/index.html,而实际的域webflow.test.co工作正常。

使用
proxy\u pass
nginx充当反向代理:它只是将请求转发到代理站点,等待响应并返回它。所以你们不应该期望在客户端重定向。明白-很高兴知道。谢谢。那么你的意思是使用https连接到
webflow
?您的意思是用
proxy\u set\u header
?@RyanSpicer覆盖主机头,所以Davide comments回答了您的问题,还是仍然需要帮助?对这两个都是。虽然我不确定使用https的语法(我应该直接将代理设置为https吗?)。
upstream nodejs {
    server 127.0.0.1:8081;
    keepalive 256;
}

# Redirect all non-HTTPS to non-WWW HTTPS
server {
    listen 8080;
    server_name "~^(?:www\.)?(.*)$";
    return 301 https://$host$request_uri;
}

# Redirect WWW HTTP to non-WWW HTTP
server {
    listen 4430;
    server_name "~^www\.(.*)$";
    return 301 https://$1$request_uri;
}

server {
    location / {
        proxy_pass https://webflow.test.co;
        proxy_set_header Connection "";
        proxy_http_version 1.1;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto https;
    }
}

# Reverse-proxy to http://nodejs
server {
    listen 4430;
    server_name "~^(?!www\.).*$";

    client_max_body_size 50M;

    location ~ /(?<all>.+) {
        proxy_pass http://nodejs;
        proxy_set_header Connection "";
        proxy_http_version 1.1;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}