Apache nginx和DNS子域,重定向太多

Apache nginx和DNS子域,重定向太多,apache,nginx,web,subdomain,Apache,Nginx,Web,Subdomain,我刚刚安装了nginx,并将其设置为在apache安装上工作。事实上,我的规则是: server { listen 80; server_name example.com; location / { proxy_set_header X-Readl-IP $remote_addr; proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header Host $host

我刚刚安装了nginx,并将其设置为在apache安装上工作。事实上,我的规则是:

server {
    listen 80;

    server_name example.com;

   location / {
       proxy_set_header X-Readl-IP $remote_addr;
       proxy_set_header X-Forwarded-For $remote_addr;
       proxy_set_header Host $host;
       proxy_pass http://example.com:8080;
   }

   location ~ /\.ht {
       deny all;
   }
}
我想通过以下方式配置子域:

server {
   listen 80;
   server_name sub.example.com;

    location / {
        proxy_pass http://example.com:8080/sub;
    }

    location ~/\.ht {
        deny all;
    }
}
并按如下方式配置我的DNS:

NAME     |     TYPE     |     TARGET
//empty         A           45.23.67.89
 sub           CNAME        example.com
我等待传播,但我在chrome中得到了“太多重定向”

响应总是301,并重定向到IP:80,我猜这是由于DNS中的一行引起的。。。然而,domain.com确实重定向到apache,我确实得到了我们都非常熟悉的“它可以工作”

谁能给我指一下正确的方向吗

谢谢

更新

我添加了另一个subdowmain,sub-sub,完全遵循相同的过程,但它神奇地工作了。。。需要帮助

Put

ProxyRequests off 
ProxyPass / http://127.0.0.1:2368/ 
ProxyPassReverse / http:/127.0.0.1:2368/               
</VirtualHost>
ProxyRequests关闭
ProxyPass/http://127.0.0.1:2368/ 
ProxyPassReverse/http:/127.0.0.1:2368/
此配置取自Apache2,不确定此配置是否适用于Nginx,但此配置已在Apache2上修复。显然,更改本地主机的端口。该配置用于Ghost博客

这将把访问者重定向到一个特定的端口,如果启用了HTTPS或SSL,并且收到了太多的重定向请求,这是很好的。您可以将端口设置为443(SSL端口)。

Put

ProxyRequests off 
ProxyPass / http://127.0.0.1:2368/ 
ProxyPassReverse / http:/127.0.0.1:2368/               
</VirtualHost>
ProxyRequests关闭
ProxyPass/http://127.0.0.1:2368/ 
ProxyPassReverse/http:/127.0.0.1:2368/
此配置取自Apache2,不确定此配置是否适用于Nginx,但此配置已在Apache2上修复。显然,更改本地主机的端口。该配置用于Ghost博客

这将把访问者重定向到一个特定的端口,如果启用了HTTPS或SSL,并且收到了太多的重定向请求,这是很好的。您可以将端口设置为443(SSL端口)。

确定

我在proxy_pass指令中添加了头,它成功了

proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
但是,它仍然在url的末尾添加了一个斜杠(/),这意味着当我进入
sub.example.com
时,我得到
sub.exmaple.com/
确定解决

我在proxy_pass指令中添加了头,它成功了

proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
然而,它仍然在url的末尾添加了一个斜杠(/),这意味着当我进入
sub.example.com
时,我会得到
sub.exmaple.com/