I currently have Nginx running as a reverse proxy in front of Apache on the same server to serve static contents. i.e. Nginx listening to port 80 then proxy_pass to 127.0.0.1:8000, Apache listening to 127.0.0.1:8000.
I am trying to setup Apache to serve SSL / https content. After I setup Apache and a new virtual host to listen to :443, I am getting 502 Bad gateway from Nginx on HTTP connections. I checked the Nginx logs and it says "conection refused while connecting to upstream
http://127.0.0.1:8000".
I am not sure if I am approaching this correctly. Should Nginx listen to both 443 and 80 then both proxy_pass to 127.0.0.1:8000? Or do I setup a separate VirtualHost on apache to listen for 443?
Current setup:
NGINX:server {
listen 80;
root /www
index index.php index.html index.htm;
server_name example.com;
.....
location ~ \.php$ {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
proxy_pass
http://127.0.0.1:8000; proxy_read_timeout 240s;
}
}
Apache ports.conf:NameVirtualHost 127.0.0.1:8000
Listen 127.0.0.1:8000
<IfModule mod_ssl.c>
NameVirtualHost *:443
Listen 443
</IfModule>
<IfModule mod_gnutls.c>
Listen 443
</IfModule>
Apache Vhost1<VirtualHost 127.0.0.1:8000>
ServerName example.com
ServerAlias *.example.com
DocumentRoot /www
...
</VirtualHost>
Apache Vhost2<VirtualHost *:443>
ServerName example.com
ServerAlias *.example.com
DocumentRoot /www
...
</VirtualHost>