在以下配置中,当上游服务器返回 HTTP 200 OK 响应以外的响应时,对 hostnameb.example.org 的请求缺少 X-custom-server-info 标头。
hostnamea.example.org 响应正确(包括标头)。
知道为什么或如何解决它吗?
worker_processes auto;
worker_rlimit_nofile 8192;
pid /opt/bitnami/nginx/tmp/nginx.pid;
events {
worker_connections 4096;
}
http {
include /opt/bitnami/nginx/conf/mime.types;
add_header X-custom-server-info "someinfo" always;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Forwarded "";
proxy_http_version 1.1;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_connect_timeout 180;
proxy_send_timeout 180;
proxy_read_timeout 180;
proxy_buffers 32 4k;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Host $host;
#proxy_set_header X-Forwarded-Proto $scheme;
#proxy_set_header X-Forwarded-Port $server_port;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Forwarded-Port 443;
server_tokens off;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
server_names_hash_bucket_size 128; # this seems to be required for some vhosts
default_type application/octet-stream;
resolver dns-default.openshift-dns.svc.cluster.local valid=300s;
server {
listen 8081;
server_name hostnamea.example.org;
set $bff "http://bff.project.svc.cluster.local";
location / {
proxy_pass $bff;
}
}
server {
listen 8081;
server_name hostnameb.example.org;
set $bff "http://bff.project.svc.cluster.local";
location / {
proxy_pass $bff;
add_header Access-Control-Allow-Origin https://external.example.org always;
add_header Access-Control-Allow-Credentials true always;
}
}
log_format upstreamlog '[$time_local] "$request" UA:"$http_user_agent"';
access_log /opt/bitnami/nginx/logs/access.log upstreamlog;
error_log /opt/bitnami/nginx/logs/error.log;
}