S
S
Shohruh Uz2014-08-23 14:29:00
Nginx
Shohruh Uz, 2014-08-23 14:29:00

How to redirect from http:// to https:// for nginx?

How to redirect from http:// to https:// in nginx ?
Can it be done via .htaccess ?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
VMCLOUD, 2014-08-23
@shohruhuz

server {
listen IP_ADDRESS;
server_name site.ru www.site.ru;
rewrite ^ https://site.ru$request_uri? permanent; #301-redirect
}
server {
listen IP_ADDRESS:443 ssl;
server_name site.ru;
root /opt/redmine/public;
passenger_enabled on;
client_max_body_size 10m; # Max attachemnt size
keepalive_timeout 60;
ssl_certificate /opt/nginx/ssl/cetr.chained.crt;
ssl_certificate_key /opt/nginx/ssl/cert.key;
ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers "RC4:HIGH:!aNULL:!MD5:!kEDH";
add_header Strict-Transport-Security 'max-age=604800';
}
}

K
kompi, 2014-08-23
@kompi

if ($scheme = http) {
    return 301 https://$host$request_uri;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question