0

We use multiple servers as reverse proxy for all domains we manage and there we also generate letsencrypt ssl certs for each domain/website. Last month, approx 30 days ago, about 30 websites/domains and generated ssl certs, all worked ok, the 301 redirect is working fine even today fot those 30 websites/domains. Yesterday we added another 20 websites/domains, with same settings as the other 30 older websites, but all this 20 does get redirected too many times.

For old domains https work just fine:

curl -I https://old-domain.com/
HTTP/1.1 200 OK
Date: Wed, 06 Jun 2018 07:41:19 GMT
Content-Type: text/html; charset=UTF-8
Content-Length: 1
Connection: keep-alive
Server: nginx

For the new websites we added we get:

curl -I https://new-domain.com/
HTTP/1.1 301 Moved Permanently
Date: Wed, 06 Jun 2018 07:36:33 GMT
Content-Type: text/html
Content-Length: 178
Connection: keep-alive
Server: nginx
Location: https://new-domain.com/

Neginx conf file test results:

nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

We also tested the ssl cert for the new domains in sslabs.com and it shows A grade ssl cert.

We also used domains from different registrars, with same outcome. At this stage the servers we used are on digitalocean and hetzner, both with same problem. I don't know what we did wrong, but here are my nginx settings for domains/websites:

Here is nginx.conf:

user  nginx;
worker_processes  4;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;


events {
    worker_connections  4096;
}
worker_rlimit_nofile 30000;

http {
    include       /etc/nginx/mime.types;

    sendfile        on;
    keepalive_timeout  10;

    proxy_max_temp_file_size 0;

    server_names_hash_bucket_size 64;
    server_names_hash_max_size 1024;

    include /etc/nginx/conf.d/websites.conf;
}

And here is websites.conf:

 server {
         listen       80;
         server_name     old-domain.com www.old-domain.com;
         return 301 https://$server_name$request_uri;
 }
 server {
         listen       443 ssl;
         server_name     old-domain.com www.old-domain.com;

         ssl on;
         ssl_certificate /etc/ssl/old-domain.com/fullchain.pem; #    managed by Certbot
         ssl_certificate_key /etc/ssl/old-domain.com/privkey.pem; #    managed by Certbot
         ssl_trusted_certificate /etc/ssl/old-domain.com/fullchain.pem; #    managed by Certbot
         include ssl.conf;

         location / {
                 proxy_pass   http://123.123.123.123;
         }
 }

 server {
         listen       80;
         server_name     new-domain.com www.new-domain.com;
         return 301 https://$server_name$request_uri;
 }
 server {
         listen       443 ssl;
         server_name     new-domain.com www.new-domain.com;

         ssl on;
         ssl_certificate /etc/ssl/new-domain.com/fullchain.pem; #    managed by Certbot
         ssl_certificate_key /etc/ssl/new-domain.com/privkey.pem; #    managed by Certbot
         ssl_trusted_certificate /etc/ssl/new-domain.com/fullchain.pem; #    managed by Certbot
         include ssl.conf;

         location / {
                 proxy_pass   http://123.123.123.123;
         }
 }

AGAIN: All works correctly for older domains/websites (in above example for old-domain.com), we only have problem with everything new we add (in above example for new-domain.com)

Any sugeestion?

PS: We also restarted server to see if it affects anything, but of course no. Also, nginx restart and/or reload doesn't solve the problem. PS2: We don't use cloudflare at all. PS3: Normal http non-https/redirect reverse proxy works corectly

  • 1
    Solved. proxy_pass had a wrong ip :) – becoolflyer Jun 7 '18 at 7:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.