← 所有代码文件

nginx.conf

反向代理到 :3000 上的应用,带 SPA 回退和 gzip。

server {
    listen 80;
    server_name example.com;
    root /var/www/html;
    index index.html;

    gzip on;
    gzip_types text/css application/javascript application/json image/svg+xml;

    # Serve static, fall back to index.html (SPA)
    location / {
        try_files $uri $uri/ /index.html;
    }

    # Proxy API to the app server
    location /api/ {
        proxy_pass http://127.0.0.1:3000;
        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;
    }
}

关于此工具

反向代理到 :3000 上的应用,带 SPA 回退和 gzip。

开箱即用的 nginx.conf——查看内容、复制,或以正确的文件名下载。免费,100% 在浏览器中运行。