server { listen 80; server_name aria2.example.com; return 301 https://$host$request_uri; } server { listen 443; server_name aria2.example.com; ssl_certificate /etc/nginx/ssl/example.com.crt; ssl_certificate_key /etc/nginx/ssl/example.com.key; location / { proxy_pass http://172.17.3.25:8080; } location /jsonrpc { proxy_pass http://172.17.3.25:6800; proxy_http_version 1.1; proxy_set_header Connection "upgrade"; proxy_set_header Host $host; proxy_set_header Upgrade $http_upgrade; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Real-IP $remote_addr; proxy_redirect off; } }