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

June 12, 2019 154 views
Nginx Apache

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.

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.

Have another answer? Share your knowledge.