码上灵感
  • 经验

    • 服务器

      • 操作系统
      • 网络配置
      • ssh配置
      • 压力测试
      • IPMI
    • 基础工具

      • xshell
      • xftp
    • 基础环境

      • anaconda
      • v2ray
      • cuda
      • docker
      • nginx
      • ufw
      • git lfs 大文件
    • ubuntu

      • virtualbox
    • minio

      • 安装
    • postgres

      • 安装
    • AI相关折腾

      • maxkb
      • huggingface
      • vllm
      • ktransformers
      • wan2.1
    • 疑难杂症

      • ubuntu自动更新
      • xshell隧道转发失败
      • video自动播放不成功的问题
      • 3d模型快速生成

nginx

安装

sudo apt install -y nginx

常用命令

sudo systemctl start nginx    # 启动 Nginx
sudo systemctl stop nginx     # 停止 Nginx
sudo systemctl restart nginx  # 重启 Nginx

配置文件目录

/etc/nginx/sites-available

启用目录

/etc/nginx/sites-enabled

测试nginx

sudo nginx -t

配置文件示例

server {
    listen 3201 ssl;
    server_name aigc.mspharm.com;  # 修改标记,这里修改成你的域名

    # 使用你的SSL证书
    ssl_certificate /mnt/sdb4/ssl/mspharm.com.pem;  # 修改标记,这里修改pem证书文件位置
    ssl_certificate_key /mnt/sdb4/ssl/mspharm.com.key;  # 修改标记,这里修改key证书文件位置

    # 流式输出
    proxy_cache off;
    proxy_buffering off; 
    chunked_transfer_encoding on;
    tcp_nopush on; 
    tcp_nodelay on;
    keepalive_timeout 600;
    client_max_body_size 10240M;
    # 其他SSL设置
    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_ciphers HIGH:!aNULL:!MD5;
    ssl_prefer_server_ciphers on;

    location / {
        proxy_pass http://127.0.0.1:8080;  # # 修改标记,修改为应用程序的实际地址
        client_max_body_size 10240M;
        proxy_connect_timeout  600;
        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;
        
    }
}
Prev
docker
Next
ufw