Re: [mezzanine-users] Redirect 301 NON www TO www
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 mezzanine-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [mezzanine-users] Redirect 301 NON www TO www
On Mon, Sep 4, 2017 at 11:03 AM, Matic Nočwrote: > I have ubuntu 16.04 and when i ssh i see only mezzanine cache and > .virtualenvs, logs folders I am not at laptop now, I cannot send you whole > schema. I have searched around for quite some time and I cannot find etc > folder. Where is it supposed to be ? > https://github.com/stephenmcd/mezzanine/blob/master/mezzanine/project_template/fabfile.py#L97 -- 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 mezzanine-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [mezzanine-users] Redirect 301 NON www TO www
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:) -- 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 mezzanine-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [mezzanine-users] Redirect 301 NON www TO www
I have ubuntu 16.04 and when i ssh i see only mezzanine cache and .virtualenvs, logs folders I am not at laptop now, I cannot send you whole schema. I have searched around for quite some time and I cannot find etc folder. Where is it supposed to be ? Thank you! -- 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 mezzanine-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [mezzanine-users] Redirect 301 NON www TO www
That sure is a problem! The path should be `/etc/nginx/` not `etc/nginx`. What OS you are using on your VPS? Regarding the templates, you are encouraged to modify those in your project to your heart's content. Do not modify Mezzanine itself, only the templates copied during the deploy to the root of your project. again, hth! -ken On Mon, Sep 4, 2017 at 10:38 AM, Matic Nočwrote: > The problem is that on my vps I cannot find etc/nginx folder after i make > mezzanine deploy. > > -- > 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 mezzanine-users+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- 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 mezzanine-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [mezzanine-users] Redirect 301 NON www TO www
The problem is that on my vps I cannot find etc/nginx folder after i make mezzanine deploy. -- 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 mezzanine-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [mezzanine-users] Redirect 301 NON www TO www
Hi Matic, This is an Nginx question and has nothing to do with Mezzanine (or Django). https://www.digitalocean.com/community/questions/redirecting-non-www-to-www-in-nginx provides a quick solution to your problem. hth! -ken On Mon, Sep 4, 2017 at 8:13 AM, Matic Nočwrote: > Helllo, > > I have two questions. > 1) On my deployed mezzanine I cannot find nginx conf. file (etc/nginx/ > repo). > 2) I have two domains "DOMAINS": ["www.example.com", "example.com"], in > my fab file, and I want to edit ngnix.conf.template file so it will be able > to redirect 301 the non www domains to www, but the problem is that > mezzanine deploy makes only one server. Is it possible to add redirect > inside the template somehow? > > server { > > listen 80; > %(ssl_disabled)s listen 443 ssl; > server_name %(domains_nginx)s; > client_max_body_size 35M; > keepalive_timeout15; > error_log /home/%(user)s/logs/%(proj_name)s_error_nginx.log info; > > %(ssl_disabled)s ssl_certificate conf/%(proj_name)s.crt; > %(ssl_disabled)s ssl_certificate_key conf/%(proj_name)s.key; > %(ssl_disabled)s ssl_session_cacheshared:SSL:10m; > %(ssl_disabled)s ssl_session_timeout 10m; > %(ssl_disabled)s ssl_ciphers > ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA; > %(ssl_disabled)s ssl_prefer_server_ciphers on; > %(ssl_disabled)s ssl_protocols TLSv1.2 TLSv1.1 TLSv1; > > # Deny illegal Host headers > if ($host !~* ^(%(domains_regex)s)$) { > return 444; > } > > location / { > proxy_redirect off; > proxy_set_headerHost$host; > proxy_set_headerX-Real-IP $remote_addr; > proxy_set_headerX-Forwarded-For > $proxy_add_x_forwarded_for; > proxy_set_headerX-Forwarded-Protocol$scheme; > proxy_pass http://%(proj_name)s; > } > > location /static/ { > root%(proj_path)s; > access_log off; > log_not_found off; > expires 30d; > } > > location /robots.txt { > root%(proj_path)s/static; > access_log off; > log_not_found off; > } > > location /favicon.ico { > root%(proj_path)s/static/img; > access_log off; > log_not_found off; > } > > } > > > > -- > 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 mezzanine-users+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- 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 mezzanine-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[mezzanine-users] Redirect 301 NON www TO www
Helllo, I have two questions. 1) On my deployed mezzanine I cannot find nginx conf. file (etc/nginx/ repo). 2) I have two domains "DOMAINS": ["www.example.com", "example.com"], in my fab file, and I want to edit ngnix.conf.template file so it will be able to redirect 301 the non www domains to www, but the problem is that mezzanine deploy makes only one server. Is it possible to add redirect inside the template somehow? server { listen 80; %(ssl_disabled)s listen 443 ssl; server_name %(domains_nginx)s; client_max_body_size 35M; keepalive_timeout15; error_log /home/%(user)s/logs/%(proj_name)s_error_nginx.log info; %(ssl_disabled)s ssl_certificate conf/%(proj_name)s.crt; %(ssl_disabled)s ssl_certificate_key conf/%(proj_name)s.key; %(ssl_disabled)s ssl_session_cacheshared:SSL:10m; %(ssl_disabled)s ssl_session_timeout 10m; %(ssl_disabled)s ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA; %(ssl_disabled)s ssl_prefer_server_ciphers on; %(ssl_disabled)s ssl_protocols TLSv1.2 TLSv1.1 TLSv1; # Deny illegal Host headers if ($host !~* ^(%(domains_regex)s)$) { return 444; } location / { proxy_redirect off; proxy_set_headerHost$host; proxy_set_headerX-Real-IP $remote_addr; proxy_set_headerX-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_headerX-Forwarded-Protocol$scheme; proxy_pass http://%(proj_name)s; } location /static/ { root%(proj_path)s; access_log off; log_not_found off; expires 30d; } location /robots.txt { root%(proj_path)s/static; access_log off; log_not_found off; } location /favicon.ico { root%(proj_path)s/static/img; access_log off; log_not_found off; } } -- 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 mezzanine-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.