当我转到http://git.niklasrosenstein.com时,我总是被重定向到http://niklasrosenstein.com。然后它实际上提供内容,好像下面的服务器块匹配,但当然在错误的域下!我试图从2个小时后找到这个问题的根源,但我现在就在我开始的时候。
这是整个NGinx配置中唯一的活动server
块。
## GitLab
##
## Lines starting with two hashes (##) are comments with information.
## Lines starting with one hash (#) are configuration parameters that can be uncommented.
##
##################################
## CONTRIBUTING ##
##################################
##
## If you change this file in a Merge Request, please also create
## a Merge Request on https://gitlab.com/gitlab-org/omnibus-gitlab/merge_requests
##
###################################
## configuration ##
###################################
##
## See installation.md#using-https for additional HTTPS configuration details.
upstream gitlab-workhorse {
server unix:/home/git/gitlab/tmp/sockets/gitlab-workhorse.socket fail_timeout=0;
}
## Normal HTTP host
server {
## Either remove "default_server" from the listen line below,
## or delete the /etc/nginx/sites-enabled/default file. This will cause gitlab
## to be served if you visit any address that your server responds to, eg.
## the ip address of the server (http://x.x.x.x/)n 0.0.0.0:80 default_server;
listen 80;
# listen [::]:80 ipv6only=on;
server_name git.niklasrosenstein.com;
server_tokens off; ## Don't show the nginx version number, a security best practice
root /home/git/gitlab/public;
## See app/controllers/application_controller.rb for headers set
## Individual nginx logs for this GitLab vhost
access_log /var/log/nginx/gitlab_access.log;
error_log /var/log/nginx/gitlab_error.log;
location / {
client_max_body_size 0;
gzip off;
## https://github.com/gitlabhq/gitlabhq/issues/694
## Some requests take more than 30 seconds.
proxy_read_timeout 300;
proxy_connect_timeout 300;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Host $http_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_pass http://gitlab-workhorse;
}
}
以下是Chrome开发者控制台的请求/响应信息。
发生了什么事?我希望NGinx匹配git.niklasrosenstein.com
的服务器块!
PS:虽然我没有解决这个问题,但我重新启用了子域https://blog.niklasrosenstein.com,但上述行为保持不变
更新1 我更新了我的/etc/hosts
文件,以包含git.niklasrosenstein.com
而不是127.0.0.1
的VPS的真实公共IP。这暂时解决了问题,但是一旦我重新激活了一个执行重写的块,就会再次出现同样的问题。
server {
# Permanent redirect from the old domain and the root domain name
# to the blog domain.
listen 80;
server_name niklasrosenstein.de
www.niklasrosenstein.de
niklasrosenstein.com
www.niklasrosenstein.com;
access_log /home/www-data/blog/access-redirect.log access_csv_format;
return 301 $scheme://blog.niklasrosenstein.com$request_uri;
}
更新2 这似乎是Unicorn而不是NGinx的问题。关于GitLab CE的问题:https://gitlab.com/gitlab-org/omnibus-gitlab/issues/1063