Answer the question
In order to leave comments, you need to log in
Why is there no redirect from http to https?
there are 2 sites, here are their configs
upstream node {
server 127.0.0.1:8080 fail_timeout=20s;
}
server {
server_name site1.com;
return 301 https://$server_name$request_uri;
}
server {
server_name site1.com www.site1.com;
listen 443 ssl;
ssl on;
ssl_certificate /var/www/site1.com/ssl/certificate.pem;
ssl_certificate_key /var/www/site1.com/ssl/key.key;
ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers "RC4:HIGH:!aNULL:!MD5:!kEDH";
add_header Strict-Transport-Security 'max-age=604800';
root /var/wwwsite1.com/public;
index index.php index.html index.htm;
rewrite ^/(.*)/$ /$1 permanent;
access_log /var/log/nginx/site1.com.access.log;
error_log /var/log/nginx/site1.com.error.log;
location /ws {
proxy_pass http://node;
proxy_http_version 1.1;
proxy_set_header Upgrade websocket;
proxy_set_header Connection upgrade;
}
location / {
try_files $uri $uri/ /index.php?$query_string;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
client_max_body_size 300m;
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
server {
server_name site2.com;
return 301 https://$server_name$request_uri;
}
server {
server_name site2.com ;
listen 443 ssl;
ssl on;
ssl_certificate /var/www/html/ssl/certificate.pem;
ssl_certificate_key /var/www/html/ssl/key.key;
root /var/www/html/public;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
Answer the question
In order to leave comments, you need to log in
Ports must be specified:
server {
listen 80;
listen [::]:80;
server_name site.ru www.site.ru;
return 301 https://$server_name$request_uri;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question