server { listen 80; listen [::]:80; server_name jp1.zhihubaiduxiaohongshu.top; server_name i1.hdslb.com; root /var/www/html; index index.html index.htm index.nginx-debian.html; location / { # First attempt to serve request as file, then # as directory, then fall back to displaying a 404. try_files $uri $uri/ =404; } location /m { # Check if the connection is a WebSocket upgrade request if ($http_upgrade !~* "websocket") { return 404; } proxy_pass http://127.0.0.1:8080; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header Host "i1.hdslb.com"; } } server { listen 443 ssl http2; listen [::]:443 ssl http2; server_name jp1.zhihubaiduxiaohongshu.top; root /var/www/html; index index.html index.htm index.nginx-debian.html; location / { # First attempt to serve request as file, then # as directory, then fall back to displaying a 404. try_files $uri $uri/ =404; } location /m { if ($http_upgrade !~* "websocket") { return 404; } proxy_pass http://127.0.0.1:8080; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header Host "i1.hdslb.com"; } ssl_certificate /etc/letsencrypt/live/zhihubaiduxiaohongshu.top/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/zhihubaiduxiaohongshu.top/privkey.pem; include /etc/letsencrypt/options-ssl-nginx.conf; ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; }