我在configurationDebian 8机器上的nginx和apache时遇到了一个问题。 我使用nginx的反向代理,它被设置为在HTTPS上运行(它的工作原理就像一个魅力)。 但是,当请求被发送到Apache,$ _SERVER ['HTTPS']是空的,虽然它应该是“开”(无论如何,这就是我想实现)? 这是我的Apacheconfiguration:
<VirtualHost 127.0.0.1:8080> ServerName shop.mywebsite.com ServerAdmin webmaster@localhost DocumentRoot /var/www_shop ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined LogLevel debug <Directory "/"> Require all granted </Directory> </VirtualHost>
下面是我的nginx congif,部分代理密码:
location ~ \.php { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header Host $host; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Original-Request $request_uri; add_header Front-End-Https on; proxy_pass http://127.0.0.1:8080; }
任何帮助,任何线索,赞赏;)谢谢,奥利维尔。
如果与Web服务器的连接已通过HTTPS,则您正在查找的HTTPS状态会被设置。 由于您正在Apache中查找此值,但只有Nginx正在通过HTTPS和Apache通过Nginx的HTTP请求处理请求,所以状态必须是no-HTTPS。
在你的Nginx代理configuration中,你将会设置一些额外的头文件。 你必须做的是,在Apache中检查这些头并覆盖HTTPS状态标志
因此,您必须在Apache中安装并激活mod_setenvif ,并将以下内容添加到您的Apacheconfiguration中:
<IfModule mod_setenvif.c> SetEnvIf X-Forwarded-Proto "https" HTTPS=on </IfModule>
在你的Nginxconfiguration中缺less一个设置。 只要你的Apache没有多个虚拟主机,没关系,但是我build议把下面的代码添加到你的Nginxconfiguration中:
proxy_http_version 1.1;
通过设置这个Nginx在HTTP / 1.1中对Apache说话。 默认是HTTP / 1.0。