我是Nginx的新手,我遇到了一些允许webhook访问服务器的问题。每当webhook尝试向我的Django服务器发送POST时,我都会在访问日志中看到它:
54.234.20.81 - - [02 / Jan / 2013:18:11:57 +0000]" POST / contract / events HTTP / 1.1" 403 2319" - " " - " 54.234.20.81 - - [02 / Jan / 2013:18:11:58 +0000]" POST / contract / events HTTP / 1.1" 403 2319" - " " - " 54.234.20.81 - - [02 / Jan / 2013:18:11:58 +0000]" POST / contract / events HTTP / 1.1" 403 2319" - " " - "
我不确定如何授予对此IP的访问权限,以免被禁止访问。我在Ramhost上托管,Nginx目录似乎是/ etc / nginx /。该目录有一个nginx.conf,还有一个sites-available文件夹和一个启用站点的文件夹。
以下是sites-available中的配置文件(在此文件的网站中有一个符号链接):
upstream djangoserv {
server 127.0.0.1:8080;
}
server {
listen 80;
server_name nameblr.com www.nameblr.com;
access_log /home/yorango/yorangosite/logs/yorangosite-access.log;
error_log /home/yorango/yorangosite/logs/yorangosite-error.log;
location /static/ {
alias /home/yorango/yorangosite/static/;
expires 30d;
}
location /media/ {
alias /home/yorango/yorangosite/static/;
expires 30d;
}
location / {
# host and port to fastcgi server
allow 54.242.81.184;
include fastcgi_params;
fastcgi_pass 127.0.0.1:8080;
fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param SERVER_NAME $server_name;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_pass_header Authorization;
fastcgi_intercept_errors off;
fastcgi_split_path_info ^()(.*)$;
}
}
这是nginx.conf文件,它位于/ etc / nginx /文件夹中。
user www-data;
worker_processes 1;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
# multi_accept on;
}
http {
include /etc/nginx/mime.types;
access_log /var/log/nginx/access.log;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
tcp_nodelay on;
gzip on;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
我不确定"允许54.242.81.184;"是在正确的位置,或者site-available中的文件如何与nginx.conf一起工作,但是任何帮助都表示赞赏!!
答案 0 :(得分:2)
你确定问题是Nginx吗?您是否为Django项目启用了CSRF保护?我非常确定当CSRF检查失败时,Django将发出403。
查看此问题以获取更多信息:Django CSRF check failing with an Ajax POST request