在 nginx 中托管的 webapp 不接收标头

问题描述 投票:0回答:0

我在 nginx 中托管了一个 webapp,它需要向托管在同一 nginx 服务器中的 api 服务器发出 http 请求,req.body 数据在两台服务器之间成功运行,但托管在中的 webapp 未收到授权标头nginx,但在本地运行 webapp 时,api 服务器可以接收标头。

这是我的 api 服务器块

   server {


        #root /var/www/html;

        # Add index.php to the list if you are using PHP
        index index.html index.htm index.nginx-debian.html;

        server_name bio.api.mindvisiontechnologies.com;

        location / {
        proxy_pass http://localhost:7777; #whatever port your app runs on
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_set_header Authorization $http_authorization;
        proxy_cache_bypass $http_upgrade;

        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }



    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/bio.api.mindvisiontechnologies.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/bio.api.mindvisiontechnologies.com/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}

这是WEBAPPP服务器块

server {
        root /var/www/html/bio.mindvisiontechnologies.com;
        index index.html index.htm;
        server_name bio.mindvisiontechnologies.com;


   location / {
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Authorization $http_authorization;

        try_files $uri $uri/ /index.html;
   }




    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/bio.mindvisiontechnologies.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/bio.mindvisiontechnologies.com/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}
server {
    if ($host = bio.mindvisiontechnologies.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


        server_name bio.mindvisiontechnologies.com;
    listen 80;
    return 404; # managed by Certbot


}

这是我的 NGINX 配置

user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;

events {
        worker_connections 768;
        # multi_accept on;
}

http {

        ##
        # Basic Settings
        ##
        underscores_in_headers on;
        sendfile on;
        tcp_nopush on;
        types_hash_max_size 2048;
        # server_tokens off;

        # server_names_hash_bucket_size 64;
        # server_name_in_redirect off;

        include /etc/nginx/mime.types;
        default_type application/octet-stream;

        ##
        # SSL Settings
        ##

        ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # Dropping SSLv3, ref: POODLE
        ssl_prefer_server_ciphers on;

        ##
        # Logging Settings
        ##

        log_format custom '"$request" $status $body_bytes_sent '
                          '"$http_referer" "$http_user_agent" '
                          '"$http_authorization"'
                          '$request_body';





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

        ##
        # Gzip Settings
        ##

        gzip on;

        # 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/javascript text/xml application/xml application/xml+rss text/javascript;

        ##
        # Virtual Host Configs
        ##

        include /etc/nginx/conf.d/*.conf;
        include /etc/nginx/sites-enabled/*;
}

谁能帮我解决这个问题

nginx nginx-reverse-proxy nginx-config
© www.soinside.com 2019 - 2024. All rights reserved.