HTTP Redirect on NGINX

53 views
Skip to first unread message

Brian Whitehouse

unread,
Mar 30, 2021, 10:10:36 AM3/30/21
to AtoM Users
I currently have the Archive server setup so i can access both HTTP & HTTPS sites, but i need to setup a permanent redirect for the site, so if anyone forgets to use HTTPS, then they will go directly to the secure site
My current config is below

server {
listen 80;

listen 443 ssl;
    listen [::]:443 ssl;
    include snippets/self-signed.conf;
    include snippets/ssl-params.conf;

I have the certificate information save in the self-signed.conf

I have attempted to use the suggestions as below, but nothing works, can someone point me in the correct direction, as everyone on the net has a different idea. As i have the information for the certificate in a conf file, not sure what to do about all the ssl information

server { listen 80;
server_name archives.foobar.com;
return 301 https://archives.foobar.com$request_uri;
}

server {
listen 443 ssl;
 root /usr/share/nginx/atom; server_name archives.foobar.com;
ssl on;
ssl_certificate /etc/ssl/private/foobar/aws-foobar.crt;
ssl_certificate_key /etc/ssl/private/foobar/aws-foobar.key;
ssl_session_timeout 5m;
ssl_session_cache shared:SSL:50m;
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_prefer_server_ciphers on;

 client_max_body_size 72M;

David Hume

unread,
Apr 1, 2021, 4:03:38 PM4/1/21
to AtoM Users
Hi Brian,

That's close to what we use for clients - our nginx redirect section goes like this

server {
   listen 80;
   server_name archives.foobar.com;
   location / {
       return 301 https://archives.foobar.com$request_uri;
   }
}


Not sure if you've tried that variant - let us know if it helps...


Regards,

     David Hume, Artefactual Systems Administrator
Reply all
Reply to author
Forward
0 new messages