We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
None
将服务部署在海外的公网服务器上有许多优势,包括减少API被封号的风险和实现随时随地的访问。然而,由于项目基于HTTP,尽管有访问密码功能,但非加密传输仍然存在安全隐患。为解决这个问题,我们可以使用Nginx反向代理,将服务器的443端口反向代理到80端口,实现公网的加密传输。
首先,按照项目的说明文档部署服务。假设我们将服务部署在服务器的7777端口上。
确保可以通过"服务器ip:7777"成功访问后再进行下一步。
sudo apt update sudo apt install nginx
注意:此时先不要开启Proxy,保持小云朵为灰色状态。
sudo apt install certbot python3-certbot-nginx sudo certbot --nginx -d yourdomain.com -d www.yourdomain.com
注意:申请证书时需要使用80端口,请在防火墙里打开80端口,并暂时关闭其他使用80端口的服务。
编辑Nginx配置文件:
sudo nano /etc/nginx/sites-available/default
参考配置如下:
server { listen 443 ssl; server_name yourdomain.com www.yourdomain.com; #记得改 # SSL配置,记得改 ssl_certificate /etc/letsencrypt/live/yourdomain.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/yourdomain.com/privkey.pem; ssl_protocols TLSv1.2 TLSv1.3; # 增加上传文件大小限制 client_max_body_size 100M; # 根据需求调整大小 location / { proxy_pass http://localhost:7777; # 你的HTTP服务端口 # WebSocket专用头 proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "Upgrade"; # 保持真实的客户端IP和主机信息 proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; # 防止超时问题 proxy_read_timeout 86400s; proxy_send_timeout 86400s; } }
sudo nginx -t # 检查配置是否正确 sudo systemctl reload nginx
yourdomain.com
重要提示:
client_max_body_size
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Class | 类型
None
Feature Request | 功能请求
在海外公网服务器上部署服务并配置HTTPS
将服务部署在海外的公网服务器上有许多优势,包括减少API被封号的风险和实现随时随地的访问。然而,由于项目基于HTTP,尽管有访问密码功能,但非加密传输仍然存在安全隐患。为解决这个问题,我们可以使用Nginx反向代理,将服务器的443端口反向代理到80端口,实现公网的加密传输。
1. 部署项目
首先,按照项目的说明文档部署服务。假设我们将服务部署在服务器的7777端口上。
2. 安装Nginx
3. 申请域名
4. 申请SSL证书
5. 修改Nginx配置
编辑Nginx配置文件:
参考配置如下:
6. 重新运行Nginx
sudo nginx -t # 检查配置是否正确 sudo systemctl reload nginx
7. 测试
yourdomain.com
是否可以正常跳转重要提示:
client_max_body_size
。The text was updated successfully, but these errors were encountered: