我現在寫的程式碼如下,不管用。
是需要寫rewrite規則,用正規表示式,或是if之類的?
以及:如果在nodejs中設定靜態檔案目錄,app.use(express.static(__dirname));
這樣,效能上會比nginx直接判斷處理低嗎?
server {
listen 80;
server_name xxx.wechattest.com;
root /path/to/static/root;
index index.html;
location / {
proxy_pass http://127.0.0.1:9999;//nodejs service is running on port 9999
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 100M;
client_body_buffer_size 1m;
proxy_intercept_errors on;
proxy_buffering off;
proxy_buffer_size 128k;
proxy_buffers 256 16k;
proxy_busy_buffers_size 256k;
proxy_temp_file_write_size 256k;
proxy_max_temp_file_size 0;
proxy_read_timeout 300;
}
}