Site doesn't redirect to https (have looked at suggested solutions)

Thank you for posting this helpful information. I don’t think any of the missing recent Trellis updates would be a factor.

The Nginx conf looks fine. The # Redirect some domains section works. These seem to redirect fine:

https://www.australiascience.tv -> https://australiascience.tv
http://www.australiascience.tv  -> https://australiascience.tv

Of course, the # Redirect to https section is not working for some reason.

http://australiascience.tv      -> https://australiascience.tv

Maybe configs need to be applied?

The best case scenario is that the configs just haven’t taken hold for some reason and you need to apply them. For example, perhaps there was a glitch during provisioning (server.yml) and Nginx didn’t have a chance to reload at the end of the playbook. This can happen if there is an unusually severe problem, or if you submit a keyboard interrupt while the playbook is running.

:question: Did production get a complete error-free run of server.yml?

:star: Could you SSH in as root or as the admin_user and run these commands?

# test Nginx configs
sudo nginx -t

# if no errors in output above, reload Nginx
sudo service nginx reload

:star: Assuming the commands above succeed, try clearing your browsers’ caches and testing the redirect again.

Maybe competing configs?

The # Redirect to https server block has include includes.d/australiascience.tv/*.conf;

:question: Do you have any such includes and could they be interfering?
(e.g., if they have a location / {...})

:question: Similarly, do you have any other Nginx confs (e.g., in sites-enabled or elsewhere) with a server block that contains the following directives?

  • server_name australiascience.tv;
  • listen 80;

If so, Nginx could be matching these blocks instead of the desired redirects section in /etc/nginx/sites-enabled/australiascience.tv.conf and you would need to consolidate the two competing blocks into one.

:question: Any chance you have your staging site/environment also on this same server?
:star: If so, you’ll need to use a “hostname alias in hosts file” and a unique “site key” between environments. See corresponding sections here.

2 Likes