server { listen 8443 ssl http2; server_name iot.myhost.com; if ($host != "iot.myhost.com") { return 301 https://google.com; } error_page 497 301 =307 https://$host:$server_port$request_uri; if ($allowed_country = no) { return 444; } ssl on; ssl_certificate /etc/letsencrypt/live/myhost.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/myhost.com/privkey.pem; ssl_protocols TLSv1.2 TLSv1.3; ssl_session_timeout 4h; ssl_session_cache shared:SSL:40m; ssl_ciphers 'ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256'; ssl_prefer_server_ciphers on; add_header Strict-Transport-Security "max-age=63072000; includeSubdomains; preload"; ssl_stapling on; ssl_stapling_verify on; ssl_dhparam /etc/ssl/certs/dhparams.pem; add_header X-Frame-Options SAMEORIGIN; add_header "X-XSS-Protection" "1; mode=block"; gzip off; location / { proxy_pass http://127.0.0.1:8123; proxy_set_header Host $host; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $http_connection; proxy_set_header X-Real-IP $remote_addr; proxy_redirect http:// https://; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } location /api/websocket { proxy_pass http://127.0.0.1:8123/api/websocket; proxy_set_header Host $host; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $http_connection; proxy_set_header X-Real-IP $remote_addr; proxy_redirect http:// https://; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } } #server { # listen 80; # server_name iot.myhost.com; # return 301 https://$host:$server_port$request_uri; #}