eri*_*ich 9 nginx nginx-reverse-proxy nginx-config
这在我的 Nginx 配置中有效:
# This works
proxy_pass http://GitLab-CE:9080;
Run Code Online (Sandbox Code Playgroud)
...但这并不:
# does not work
set $upstream_gitlab GitLab-CE;
proxy_pass http://$upstream_gitlab:9080;
Run Code Online (Sandbox Code Playgroud)
这是从使用连字符和不同端口的不同工作示例复制的。
# this works
set $upstream_deluge binhex-delugevpn;
proxy_pass http://$upstream_deluge:8112;
Run Code Online (Sandbox Code Playgroud)
我想也许与破折号有关,但我有另一个配置,它的名称中也使用连字符(见上文)并且它有效。我尝试过各种形式的引用,但似乎都没有帮助。这里可能发生了什么?我很茫然。GitLab-CE 不起作用但 binhex-delugevpn 起作用是怎么回事?Nginx 是否看到 CE 有一些十六进制数学?
完整上下文:
# make sure that your dns has a cname set for gitlab and that your gitlab container is not using a base url
server {
listen 443 ssl;
listen [::]:443 ssl;
server_name gitlab.*;
include /config/nginx/ssl.conf;
client_max_body_size 0;
# enable for ldap auth, fill in ldap details in ldap.conf
#include /config/nginx/ldap.conf;
location / {
# enable the next two lines for http auth
auth_basic "Restricted";
auth_basic_user_file /config/nginx/.htpasswd;
# enable the next two lines for ldap auth
#auth_request /auth;
#error_page 401 =200 /login;
include /config/nginx/proxy.conf;
resolver 127.0.0.11 valid=30s;
set $upstream_gitlab GitLab-CE;
proxy_pass http://$upstream_gitlab:9080;
}
}
Run Code Online (Sandbox Code Playgroud)
我应该指出,127.0.0.11 确实是正确的解析器,并且名称 GitLab-CE 和 binhex-delugevpn 确实可以正确解析。
当然,当变量仅被引用一次时,无需使用变量,但这遵循 linuxserver.io 的 LetsEncrypt Docker 映像中的模板。
编辑:更多上下文
这是/config/nginx/nginx.conf。
它是未经我修改的。
## Version 2018/01/29 - Changelog: https://github.com/linuxserver/docker-letsencrypt/commits/master/root/defaults/nginx.conf
user abc;
worker_processes 4;
pid /run/nginx.pid;
include /etc/nginx/modules/*.conf;
events {
worker_connections 768;
# multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
client_max_body_size 0;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# Logging Settings
##
access_log /config/log/nginx/access.log;
error_log /config/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
gzip_disable "msie6";
# 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/x-javascript text/xml application/xml application/xml+rss text/javascript;
##
# nginx-naxsi config
##
# Uncomment it if you installed nginx-naxsi
##
#include /etc/nginx/naxsi_core.rules;
##
# nginx-passenger config
##
# Uncomment it if you installed nginx-passenger
##
#passenger_root /usr;
#passenger_ruby /usr/bin/ruby;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /config/nginx/site-confs/*;
}
#mail {
# # See sample authentication script at:
# # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
#
# # auth_http localhost/auth.php;
# # pop3_capabilities "TOP" "USER";
# # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
# server {
# listen localhost:110;
# protocol pop3;
# proxy on;
# }
#
# server {
# listen localhost:143;
# protocol imap;
# proxy on;
# }
#}
daemon off;
Run Code Online (Sandbox Code Playgroud)
编辑2:
我已经证实 Nginx 在使用变量时似乎正在做一些“tolower”转换。
我将我的 GitLab 容器重命名为 gitlab-ce 并且工作正常。我将 deluge 容器重命名为 binhex-deLugevpn(并对 .conf 进行了适当的编辑),然后它停止工作。
然后我将其重命名回 binhex-deluge 但在我放入的 .conf 文件中set $upstream_deluge bInHeX-dElUgEvPn;
它奏效了。因此,来自 linuxserver/letsencrypt 的 nginx (1.14.2) 似乎对变量进行了一些较低的转换。
我试着寻找find /config -type f -print0 | xargs -0 grep -i lower,但一无所获。
| 归档时间: |
|
| 查看次数: |
12785 次 |
| 最近记录: |