我原来的nginx.conf:
events {}
http {
server {
include credentials.conf;
listen 80;
location / {
proxy_set_header Authorization $credentials;
proxy_pass [website_of_choice];
}
}
}
我credentials.conf:
set $credentials 'Basic [long_encoded_login_details]';
但这在 nginx 启动时不起作用。
答案 0 :(得分:0)
使用 .conf
作为文件结尾在某些情况下不起作用。这应该会给您一个错误,尝试在 configtest 上重新加载 nginx sudo nginx -s reload
或 nginx -t
。这取决于您的 nginx.conf。检查是否有任何 include
指令,包括给定目录中的任何 *.conf
。
使用这个
credentials.include
set $credentials 'Basic [long_encoded_login_details]';
nginx.conf
events {}
http {
server {
include credentials.include;
listen 80;
location / {
proxy_set_header Authorization $credentials;
proxy_pass [website_of_choice];
}
}
}