Question

How to install ssl on nginx which is front-end proxy to apache for subdomains

Posted June 12, 2019 344 views
NginxApache

I have Nginx on port 80 which handles abc.com, one.abc.com and two.abc.com.
For abc.com and one.abc.com, it redirects to Apache in port 8080.
For two.abc.com, it redirects to Apache in port 8081.

The task now is to upgrade to https.
Where to install the certificate - on nginx or on apache?
How does https calls hold good for the subdomains one.abc.comm and two.abc.com?

Sample nginx conf:
server {
listen 80;
servername abc.com, one.abc.com;
location / {
proxy
setheader X-Real-IP $remoteaddr;
proxysetheader Host $httphost;
proxy
pass http://127.0.0.1:8080;
}
}

server {
    listen      80;
    server_name two.abc.com;
    location / {
        proxy_set_header   X-Real-IP $remote_addr;
        proxy_set_header   Host      $http_host;
        proxy_pass         http://127.0.0.1:8081;
    }
}

Thanks in advance.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
1 answer

Hello,

You need to install the SSL certificate on Nginx and you could use a wildcard SSL certificate to cover all of your subdomains.

Hope that this helps.

Submit an Answer