Nginx SSL Ayarları

https://osmanburan.com/ubuntu-ile-asp-net-core-3-deployment/ makalesinde yayına aldığımız web uygulamasını SSL ile çalıştırmak istiyorsak nginx ayarlarının şu şekilde düzenlenmesi gereklidir.

sudo nano /etc/nginx/sites-available/default

server {
        listen 80 default_server;
        server_name _;
        return 444;
}
server {
   listen 80;
   server_name siteadi.com;
   return 301 https://$host$request_uri;
}
server {
        listen 443;
        server_name siteadi.com;
        ssl_certificate           /etc/nginx/siteadi.com.crt;
        ssl_certificate_key       /etc/nginx/siteadi.com.key;
        ssl on;
        ssl_session_cache  builtin:1000  shared:SSL:10m;
        ssl_protocols  TLSv1 TLSv1.1 TLSv1.2;
        ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4;
        ssl_prefer_server_ciphers on;
location / {
                proxy_pass         http://localhost:5010;
                proxy_http_version 1.1;
                proxy_set_header   Upgrade $http_upgrade;
                proxy_set_header   Connection keep-alive;
                proxy_set_header   Host $host;
                proxy_cache_bypass $http_upgrade;
                proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header   X-Forwarded-Proto $scheme;
        }
}

http ile 80 nolu portan gelen istekler https 443 portuna otomatik yönlendirilir. https istekleri ise reverse proxy ile asp.net core ile yayınlanan siteye bağlanıp SSL ile cevap verir.