Answer the question
In order to leave comments, you need to log in
How to redirect from www to non-www and from http to https in nginx proxy?
The task seems to be simple. There is Nginx reverse proxy and host config
server {
listen 80;
server_name www.demo.ru demo.ru;
return 301 https://$server_name$request_uri;
}
server {
listen 443;
server_name demo.ru www.demo.ru;
ssl_certificate /etc/nginx/certs/demo.ru.crt;
ssl_certificate_key /etc/nginx/certs/demo.ru.key;
ssl on;
ssl_session_cache builtin:1000shared:SSL:10m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4;
ssl_prefer_server_ciphers on;
location / {
proxy_pass http://demo_web;
}
}
When trying to access the site via https://www.demo.ru , it returns 200 status, although there should be a redirect to https://demo.ru. Ultimately, I need demo.ru www.demo.ru https://www.demo.ru to have a redirect to https://demo.ru . Where is the mistake?
Answer the question
In order to leave comments, you need to log in
You have a redirect to http and you go to https. Try logging in with http.
You don't have a redirect to without www.
add before location /
It is also not necessary to make a separate server for redirecting to https. Enable both ports (80/443) on one and add a similar redirect
if ($scheme = 'http') { return 301 https://demo.ru$request_uri;}
When trying to enter the site through https://www.demo.ru returns 200 status, although there should be a redirect.
server{
server_name www.demo.ru;
return 301 $scheme://www.demo.ru$request_uri;
}
server {
listen 80;
server_name www.demo.ru demo.ru;
return 301 https://www.demo.ru$request_uri;
}
I usually do this:
server {
listen 80;
server_name site.com www.site.com;
rewrite ^(.*) https://$server_name$1 permanent;
}
server {
listen 443 ssl;
include ssl/site.com;
server_name www.site.com;
rewrite ^(.*) https://site.com$1 permanent;
}
server {
listen 443 ssl;
include ssl/site.com;
server_name site.com;
...........
...........
...........
}
why do you have MAX(ggh.timemodified) and accordingly GROUP BY in your query? if you just need to select records by the timemodified<=1419933851 condition, grouping is not needed.
instead
of MAX(ggh.timemodified) it will be ggh.timemodified
and GROUP BY c.fullname remove
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question