On 5/09/2017 12:35 AM, Matic Noč wrote:
All the changes I have done so far were in templates od deploy. I think I will 
just put www domain in DOMAINS and in nginx template make another server with 
non www domain which redirects to www domain:)

To do the redirect in nginx, you just need something like this in your project/deploy/nginx.conf template:

# redirect all requests on www subdomain to root domain
server {
    listen 80;
    server_name www.example.com;

    add_header Strict-Transport-Security "max-age=63072000; includeSubdomains; preload";
    add_header X-Frame-Options SAMEORIGIN;
    add_header X-Content-Type-Options nosniff;

    return 301 $scheme://example.com/$request_uri;
}

Of course, replace example.com with your domain name. (and add the necessary SSL lines if you want to redirect https://www.example.com to https://example.com)

Underneath this in the config, you can just have another server {} block to describe the example.com domain and push requests through to Django/Mezzanine.

If you're using fabric to deploy, then changing the template on your development machine should be enough, and a fab deploy will transfer these changes
across to your production server.

If you want to double check, be sure to log into the production server and have a look in /etc/nginx/sites-enabled and make sure that there's a conf file there that matches your template.

If it still appears to not be working, make sure that nginx has been restarted:
%> sudo service nginx restart

Or just reboot your production server.

Hope this helps,

Seeya. Danny.


--
You received this message because you are subscribed to the Google Groups "Mezzanine 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to