Answer the question
In order to leave comments, you need to log in
How to properly set up a redirect from http to https in Symfony 3?
Good afternoon! Set up a redirect to https via nginx:
server {
location / {
location ~* ^.+\.(jpg|jpeg|gif|png|svg|js|css|mp3|ogg|mpe?g|avi|zip|gz|bz2?|rar|swf)$ {
try_files $uri $uri/ @fallback;
}
location / {
try_files /does_not_exists @fallback;
}
location ~ [^/]\.ph(p\d*|tml)$ {
try_files /does_not_exists @fallback;
}
}
location @fallback {
error_log /dev/null crit;
proxy_pass http://127.0.0.1:8080;
proxy_set_header Host $host;
rewrite ^(.*)$ https://site.ru$1 permanent;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Port $server_port;
access_log off ;
proxy_redirect http://127.0.0.1:8080 /;
}
listen [ip address]::80;
}
server {
location / {
location ~* ^.+\.(jpg|jpeg|gif|png|svg|js|css|mp3|ogg|mpe?g|avi|zip|gz|bz2?|rar|swf)$ {
try_files $uri $uri/ @fallback;
}
location / {
try_files /does_not_exists @fallback;
}
location ~ [^/]\.ph(p\d*|tml)$ {
try_files /does_not_exists @fallback;
}
}
location @fallback {
error_log /dev/null crit;
proxy_pass http://127.0.0.1:8080;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Port $server_port;
access_log off ;
proxy_redirect http://127.0.0.1:8080 /;
}
listen [ip address]:443;
}
Answer the question
In order to leave comments, you need to log in
You can configure the current server (nginx section) completely under 443 and separately for these domains raise the server for port 80, there already redirect to https
server {
listen 80;
server_name example.com www.example.com *.example.com;
# listen [::]:80;
access_log off;
#include acme;?
location / {
return 301 https://example.com$request_uri;
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question