Following this answer, I have my nginx server set up like so:
server { server_name portal.productive.city www.portal.productive.city; root /www/Productive-Website/my-app/build; index index.html index.htm; rewrite ^/(.*)/$ $1 permanent; location / { try_files $uri?$args $uri/ $uri.html?$args /index.html?$args; } listen 443 ssl; # managed by Certbot ssl_certificate /etc/letsencrypt/live/portal.productive.city/fullchain.pem; # managed by Certbot ssl_certificate_key /etc/letsencrypt/live/portal.productive.city/privkey.pem; # managed by Certbot include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot }
My other server (in the same file) (created by lets-encrypt) is:
server { if ($host = www.portal.productive.city) { return 301 https://$host$request_uri; } # managed by Certbot if ($host = portal.productive.city) { return 301 https://$host$request_uri; } # managed by Certbot listen 80; server_name portal.productive.city www.portal.productive.city; return 404; # managed by Certbot }
When I try to go to: www.portal.productive.city or www.portal.productive.city/signin I get a 500 Internal Server Error
My error-log file looks like:
2018/08/31 14:43:08 [error] 29581#29581: *25 rewrite or internal redirection cycle while internally redirecting to "/index.html", client: 74.105.149.67, server: portal.productive.city, request: "GET / HTTP/1.1", host: "www.portal.productive.city"
2018/08/31 14:43:08 [error] 29581#29581: *26 rewrite or internal redirection cycle while internally redirecting to "/index.html", client: 74.105.149.67, server: portal.productive.city, request: "GET /favicon.ico HTTP/1.1", host: "www.portal.productive.city", referrer: "https://www.portal.productive.city/"
The favicon.ico exists under path/to/repo/build
Edit: I cleared cache and restructured the server as follows:
server { server_name portal.productive.city www.portal.productive.city; root /www/Productive-Website/my-app/build; index index.html index.htm; location / { try_files $uri?$args $uri/ $uri.html?$args /index.html?$args; } listen 80; if ($scheme != "https") { return 301 https://$host$request_uri?$args; } listen 443 ssl; # managed by Certbot ssl_certificate /etc/letsencrypt/live/portal.productive.city/fullchain.pem; # managed by Certbot ssl_certificate_key /etc/letsencrypt/live/portal.productive.city/privkey.pem; # managed by Certbot include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot }
The error-file is now:
2018/08/31 15:17:54 [error] 29789#29789: *17 rewrite or internal redirection cycle while internally redirecting to "/index.html", client: 74.105.149.67, server: portal.productive.city, request: "GET /? HTTP/1.1", host: "www.portal.productive.city"
2018/08/31 15:17:54 [error] 29789#29789: *18 rewrite or internal redirection cycle while internally redirecting to "/index.html", client: 74.105.149.67, server: portal.productive.city, request: "GET /favicon.ico HTTP/1.1", host: "www.portal.productive.city", referrer: "https://www.portal.productive.city/?"