Skip to content

关于最近版本打包生成的静态文件 Nginx 配置问题 #240

Closed Answered by surmon-china
leehave asked this question in Q&A
Discussion options

You must be logged in to vote

app.use(express.static(PUBLIC_PATH))

BFF Server 的逻辑中包含基于 Node.js 启动的 static 静态资源服务,所以理论上 Nginx 仅需启动一个 server 指向对应端口的 proxy 就可以了。但如果你希望静态服务效率更高的话,可以在 Nginx 中直接拦截静态文件的后缀而直接指向应用的静态目录。

类似这样:

server {
    listen 80;
    listen [::]:80;
    listen 443 ssl http2 fastopen=3 reuseport;
    listen [::]:443 ssl http2 fastopen=3 reuseport;

    server_name domain.com www.domain.me;

    resolver_timeout 10s;
    resolver 8.8.8.8 valid=300s;

    ssl_certificate /var/xxx/ssl.cert.pem;
    ssl_certificate_key /var/xxx/ssl.cert.key;

    ssl_session_cache shared:SSL:10m;
    ssl_session_timeout 60m;
    ssl_session_tickets on;
    ssl_ci…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by leehave
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
2 participants