Need help configuring SSL on Apache w/ Nginx Reverse Proxy
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
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$ {
proxysetheader X-Real-IP $remote_addr;
proxysetheader X-Forwarded-For $remote_addr;
proxysetheader Host $host;
proxy_pass
proxyreadtimeout 240s;
}
}
Apache ports.conf:
NameVirtualHost 127.0.0.1:8000
Listen 127.0.0.1:8000
Listen 443
Apache Vhost1
ServerAlias *.example.com
DocumentRoot /www
…
Apache Vhost2
ServerAlias *.example.com
DocumentRoot /www
…
4 Replies
It appears you have apache configured to only listen on the loopback address (127.0.0.1). Change the lines:
Listen 127.0.0.1:8000 -> Listen *:8000
and change
Edit:
Sorry - missed the part about them being on the same server. Can you curl
:~$ curl 127.0.0.1:8000
Authorization Required
This server could not verify that you
are authorized to access the document
requested. Either you supplied the wrong
credentials (e.g., bad password), or your
browser doesn't understand how to supply
the credentials required.
Apache/2.2.14 (Ubuntu) Server at 127.0.0.1 Port 8000
I added in bold:
server {
listen 80;
****listen 443 default ssl;
ssl_certificate example.crt;
sslcertificatekey example.key;****
root /www
index index.php index.html index.htm;
server_name example.com;
…..
location ~ .php$ {
proxysetheader X-Real-IP $remote_addr;
proxysetheader X-Forwarded-For $remote_addr;
proxysetheader Host $host;
proxy_pass
proxyreadtimeout 240s;
}
}