configmap nginx.conf报错:invalid number of arguments in “proxy_set_header“
问题描述使用k8s部署nginx,配置文件使用configmap:apiVersion: v1kind: ConfigMapmetadata:name: nginx-configdata:default.conf: |server {listen80;server_namelocalhost;location / {proxy_set_headerX-Forwarded-Proto
·
问题描述
使用k8s部署nginx,配置文件使用configmap:
apiVersion: v1
kind: ConfigMap
metadata:
name: nginx-config
data:
default.conf: |
server {
listen 80;
server_name localhost;
location / {
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://127.0.0.1:3000;
}
}
报错如下:
nginx: [emerg] invalid number of arguments in "proxy_set_header" directive in /etc/nginx/conf.d/default.conf:
解决
配置文件放到configmap中,$变量需要转义:
修改后如下:
apiVersion: v1
kind: ConfigMap
metadata:
namespace: txwl-ops
name: grafana-nginx-config
data:
default.conf: |
server {
listen 80;
server_name localhost;
location /ops-server {
proxy_pass http://txwl-ops-server-svc:8080/;
}
location / {
proxy_set_header X-Forwarded-Proto \$scheme;
proxy_set_header Host \$http_host;
proxy_set_header X-Real-IP \$remote_addr;
proxy_pass http://127.0.0.1:3000;
}
}
更多推荐
已为社区贡献3条内容
所有评论(0)