html - Nginx如何阻止POST请求?
问题描述
我试图阻止从 html 发送的 POST 请求:
<form action = "http://localhost:80/post_it" method ="post">
<p>Type something:</p>
<p>
<input type="text" name="n"/>
</p>
<p>
<input type="submit" value="SUBMIT"/>
</p>
</form>
在 nginx 配置中,通过以下方式:
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
keepalive_timeout 65;
include /etc/nginx/conf.d/*.conf;
}
location /post_it {
limit_except GET {
deny all;
}
}
daemon off;
但它似乎没有效果,这里是日志:
[23/May/2021 16:36:39] "GET / HTTP/1.1" 200 -
[23/May/2021 16:36:45] "GET / HTTP/1.1" 200 -
[23/May/2021 16:36:49] "POST /post_it HTTP/1.1" 302 -
[23/May/2021 16:36:49] "GET / HTTP/1.1" 200 -
提交的数据也通过烧瓶函数将用户重定向回主页,但我认为 POST 请求仍应被拒绝。Nginx 和烧瓶应用程序从一个 docker 容器运行。我在这里想念什么?