Reputation: 187
I've been trying to set up a self-signed certificate on my server (for when you visit the IP, not some domain, since I don't have any domains linked). I followed certain tutorials and made one using openssl and put my files here.
/etc/ssl/private/nginx-selfsigned.key -out /etc/ssl/certs/nginx-selfsigned.crt
I then created a configuration snippet in /etc/nginx/snippets/self-signed.conf, which looks like this.
ssl_certificate /etc/ssl/certs/nginx-selfsigned.crt;
ssl_certificate_key /etc/ssl/private/nginx-selfsigned.key;
After that, I just created an ssl-params.conf which contains the following:
ssl_protocols TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_dhparam /etc/nginx/dhparam.pem;
ssl_ciphers ECDHE-RSA-AES256-GCM-SHA512:DHE-RSA-AES256-GCM-SHA512:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384;
ssl_ecdh_curve secp384r1; # Requires nginx >= 1.1.0
ssl_session_timeout 10m;
ssl_session_cache shared:SSL:10m;
ssl_session_tickets off; # Requires nginx >= 1.5.9
resolver 8.8.8.8 8.8.4.4 valid=300s;
resolver_timeout 5s;
# Disable strict transport security for now. You can uncomment the following
# line if you understand the implications.
# add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload";
add_header X-Frame-Options DENY;
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";
And lastly, since I have no server blocks, I put the configuration in /etc/nginx/sites-available/default
Which is a simple one that I took.
server {
listen 80 default_server;
listen [::]:80 default_server;
# SSL configuration
listen 443 ssl default_server;
listen [::]:443 ssl default_server;
include snippets/self-signed.conf;
include snippets/ssl-params.conf;
return 302 https://$host$request_uri;
location ~ / {
proxy_set_header X-Forwarded-Proto $scheme;
}
}
But now whenever I visit the IP of the server, it gives me the problem of it being redirected too many times. I can't seem to find what I did wrong, so any help would be appreciated.
Upvotes: 0
Views: 846
Reputation: 75
server {listen 443 ssl;
server_name localhost;
ssl_certificate D:/yourcertificate.crt;
ssl_certificate_key D:/yourcertificate.key;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
location / {
# proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
proxy_pass http://localhost:8080;
}}
Follow this link https://youtu.be/ikbN1bYnBjg for better understanding.
Upvotes: 1