Nginx Reverse Proxy CSRF

--

最近嘗試把網站移植到 Synology Nas 的 Docker 上面,第一個遇到的問題就是 Nginx 的 Reverse Proxy。原本使用 Docker 倉庫上的 jwilder/nginx-proxy,不過後來還是決定直接用乾淨的 nginx 自己設定 conf。

第二個遇到的問題是 Laravel post 出現 419 page expired,調整 nginx 設定,在 location 裡面加上參數就可以了:

proxy_pass <後端 Server Address:Port>
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 $http_x_forwarded_proto;proxy_pass_header Set-Cookie;
proxy_max_temp_file_size 0;

然後,第三個問題則是 nginx 504 gateway time-out 問題。Laravel 本身的已經在 .htaccess 調整了,而 Nginx 的則繼續加在網站設定的 location 區塊裡面:

proxy_connect_timeout 600;
proxy_send_timeout 600;
proxy_read_timeout 600;
send_timeout 600;

如果要調整上傳上限,則還要加一條設定:

client_max_body_size 256M;

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

No responses yet

Write a response