@kr_ilya

Почему Nginx не отдает header'ы устанавливаемые helmet.js в node.js?

Проблема в том, что на локалке, без проксирования nginx, запросы к node.js возвращают такие хедеры
5dcecccf0ff08712550408.png
При проксировании запросов через Nginx эти заголовки не подхватываются. Почему? Как исправить?
НОДА:
const helmet = require('helmet')
app.use(helmet())

Nginx:
map $sent_http_content_type $expires {
    "text/html"                 epoch;
    "text/html; charset=utf-8"  epoch;
    default                     off;
}

server {
    listen          80;
    return 301 https://$host$request_uri;
}

server {
    listen 443 ssl;
    listen [::]:443 ssl;
    ssl_certificate 2
    ssl_certificate_key 1        # the port nginx is listening on
    server_name 1
    root /root/wutils;

    if ($host ~* www\.(.*)) {
        set $host_without_www $1;
        rewrite ^(.*)$ https://$host_without_www$1 permanent;
    }

    gzip            on;
    gzip_types      text/plain application/xml text/css application/javascript;
    gzip_min_length 1000;

    location /api/ {
        #return 503;
        
        proxy_redirect                      off;
        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 X-Forwarded-Proto  $scheme;
        proxy_set_header                    Upgrade $http_upgrade;
        proxy_set_header                    Connection "upgrade";
        proxy_read_timeout          30m;
        proxy_connect_timeout       30m;
        send_timeout                30m;
        proxy_pass https://127.0.0.1:3000/;
        proxy_ssl_server_name on;


    }

    error_page 500 502 503 504 /50x.html;

    location = /50x.html { 
        root /var/www/errors;
    }
}
  • Вопрос задан
  • 163 просмотра
Пригласить эксперта
Ответы на вопрос 1
fzfx
@fzfx
18,5 дм
попробуйте добавить для локейшна:
proxy_pass_header имя_заголовка;
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы