https setup issue on nginx front ending apache

0

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 on port 8080. For two.abc.com, it redirects to Apache on port 8081.

The task now is to upgrade to https. When I install certbot on nginx, still the one.abc.com redirects to http://one.abc.com

Sample nginx conf:
server {
listen 80;
servername abc.com, one.abc.com;
location / {
proxysetheader X-Real-IP $remoteaddr;
proxysetheader Host $httphost;
proxypass 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;
    }
}

Ben Ross

Posted 2019-06-14T06:10:17.610

Reputation: 11

You're not listening on port 443 you don't have any certificates configured. I presume 'two.abc.com' doesn't work too? – garethTheRed – 2019-06-14T06:36:16.220

I tried installing ssl and started listening on 443. Still https for abc.com redirects to HTTP abc.com at 8080....same for one.abc and two.abc......but i need it to be HTTPS everywhere – Ben Ross – 2019-06-14T07:59:32.960

Maybe time to edit the question? How is anyone going to be able to help you if your supplied config is nothing like what you're actually running? – garethTheRed – 2019-06-14T08:02:15.607

Except for the domain names, this is exactly what I have in my nginx conf file – Ben Ross – 2019-06-16T03:11:21.640

So you have no SSL configuration and you are not listening on port 443. Read the Nginx documentation on the listen directive and the ssl_certificate and ssl_certificate_key directives. Also, here's the first page the Google gave me when I searched for nginx ssl. Get it working with self-signed (snakeoil) certs first, then migrate to LetsEncrypt.

– garethTheRed – 2019-06-16T07:28:54.897

I have installed ssl on nginx and then Apache started throwing 402(strange) error. I had to comment all the SSL related entries then. – Ben Ross – 2019-06-17T00:45:59.790

From here 402 | Payment Required | This status code is reserved for future use, currently not returned by Apache HTTPD Server. Without the SSL* and listen directives, it's not going to work.

– garethTheRed – 2019-06-17T06:01:19.983

No answers