靜態頁接收post請求
阿新 • • 發佈:2018-05-29
nginx 靜態頁面post請求 默認情況下,nginx、apache、IIs等web服務無法響應靜態頁面的post請求,後端用來處理post請求,生產環境中不會有此問題(一般都不允許配置靜態頁面的post請求)
為什麽默認不支持靜態頁面post請求呢?
首先了解一下post請求方法,post請求一般用於提交表單或上傳文件,post請求會導致新資源的建立或舊資源的更改。就安全方面來說(排除url地址的透明性),它對比get請求會有更改資源的情況,有些靜態資源是不允許更改的,所以默認情況下web服務器上的靜態資源都不允許發起post請求。
有時候開發會寫個json頁面,它需要給領導展示,但是默認不允許發起post請求,就需要配置,這裏以nginx為例,
為什麽默認不支持靜態頁面post請求呢?
首先了解一下post請求方法,post請求一般用於提交表單或上傳文件,post請求會導致新資源的建立或舊資源的更改。就安全方面來說(排除url地址的透明性),它對比get請求會有更改資源的情況,有些靜態資源是不允許更改的,所以默認情況下web服務器上的靜態資源都不允許發起post請求。
有時候開發會寫個json頁面,它需要給領導展示,但是默認不允許發起post請求,就需要配置,這裏以nginx為例,
upstream static_backend { server localhost:80; } server { listen 80; server_name localhost; location / { root html; index index.html index.htm; } error_page 405 =200 @405; location @405 { root /html; proxy_method GET; proxy_pass http://static_backend; }
靜態頁接收post請求