Nginx 为什么我会得到代理回报;HTTP/1.1 407是否需要身份验证;?

Nginx 为什么我会得到代理回报;HTTP/1.1 407是否需要身份验证;?,nginx,proxy,gunicorn,http-status-code-407,Nginx,Proxy,Gunicorn,Http Status Code 407,我使用nginx、gunicorn、django作为后端。我已经在django中创建了API,这些API在postman甚至python代码中都可以很好地工作。但当我试图从代理服务器访问api时,它会让我“无法通过代理进行隧道”。代理返回“HTTP/1.1407 authenticationrequired.” 以下是我的nginx设置: server { listen 80; server_name mywebsite.in; return 301 https://$h

我使用nginx、gunicorn、django作为后端。我已经在django中创建了API,这些API在postman甚至python代码中都可以很好地工作。但当我试图从代理服务器访问api时,它会让我“无法通过代理进行隧道”。代理返回“HTTP/1.1407 authenticationrequired.”

以下是我的nginx设置:

server {
    listen 80;
    server_name mywebsite.in;
    return 301 https://$host$request_uri;
}

server {
    listen 80;
    server_name www.mywebsite.in;
    return 301 https://$host$request_uri;
}

server {
    listen 443 ssl ;
    server_name mywebsite.in ;
    ssl_certificate /root/mywebsite.in.crt;
    ssl_certificate_key /root/mywebsite.in.key;

    #FOR SERVING HTML PAGES
    root /root/front/mywebsite ;
    index index.html index.php;

    location /py/ {

        include proxy_params;
        proxy_set_header X-Forwarded-Protocol https ;
        proxy_ssl_session_reuse off;
        # proxy_ssl_certificate /root/mywebsite.in.crt;
        # proxy_ssl_certificate_key /root/mywebsite.in.key;
        # proxy_ssl_client_certificate /root/intermediate.crt;
        # proxy_ssl_verify off;

        proxy_pass http://localhost:8000/ ;
    }

    location /blog/ {
    proxy_pass https://mywebsitein.blogspot.in/;
    }

    location /upload {
    #  auth_basic                 "Restricted Upload";
    #  auth_basic_user_file       basic.htpasswd;
    limit_except POST          { deny all; }

    client_body_temp_path      /tmp/$request_body_file;
    client_body_in_file_only   on;
    client_body_buffer_size    128K;
    client_max_body_size       1000M;

    proxy_pass_request_headers on;
    proxy_set_header           X-FILE $request_body_file;
    proxy_set_body             off;
    proxy_redirect             off;
    proxy_pass                 http://localhost:8000/file;
    }
}
这是我的nginx.conf

user www-data;
worker_processes 4;
pid /run/nginx.pid;

events {
    worker_connections 768;
    # multi_accept on;
}

http {

    ##
    # Basic Settings
    ##

    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 65;
    types_hash_max_size 2048;
    proxy_read_timeout 1200;
    # server_tokens off;

    # server_names_hash_bucket_size 64;
    # server_name_in_redirect off;
    expires 1h;
    add_header Cache-Control no-cache;
    include /etc/nginx/mime.types;
    default_type application/octet-stream;

    ##
    # Logging Settings
    ##

    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;

    ##
    # Gzip Settings
    ##

    gzip on;
    gzip_disable "msie6";
    gzip_vary on;
    gzip_proxied any;
    gzip_comp_level 6;
    gzip_buffers 16 8k;
    gzip_http_version 1.1;
    gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/vnd.ms-fontobject application/x-font-ttf font/opentype image/svg+xml image/x-icon application/javascript;
}
我的API的形式是


请帮我找出哪里出了问题。

/py

location /py {


        port_in_redirect off;
        proxy_redirect  off;
        proxy_set_header  Host  $http_host;
        proxy_set_header  X-Real-IP  $remote_addr;
        proxy_set_header  X-Forwarded-For  $proxy_add_x_forwarded_for;

        proxy_pass http://localhost:8000;
    }

上面配置中的哪个位置是api?编辑了帖子,请检查!!您有任何形式的身份验证吗?首先,您可以无问题访问吗?是的,我可以无问题访问它,无需身份验证。就这样,我在同一页上,您是否需要先对localhost:8000进行身份验证才能访问它?同样的问题!!