简体   繁体   中英

why am I Getting a not allowed error with nginx?

I have a 405 not allowed when i request any.html or.php with POST method. im using a windows 10 machine and wsl2 with ubuntu terminal. this never happened when i used my dual booted ubuntu. why is this happening.

By default NGINX does not allow POST requests to static files (such as.html). There is a well-known hack to overcome this:

  error_page 405 =200 $uri;

It works by replacing 405 return code with 200 and serving the request instead of error page. Place it in a location when you want to allow POST requests to static files.

As for php you probably haven't configured an interpreter for scripts. Without proper configuration NGINX will show php files as plain text files. Here is an example how nginx can be configured for php-fpm .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM