nginx 正在将子域名重定向到父域名

nginx 正在将子域名重定向到父域名

我正在尝试在 subdomain.example.com 中设置 GitLab。但是当调用此 URL 时,它会被重定向到 www.example.com。以下是我的 /etc/nginx/sites-available/subdomain.example.com 文件。我遵循了此关联

upstream gitlab {
            server unix:/var/opt/gitlab/gitlab-rails/sockets/gitlab.socket;
}

server {
    listen 80;
    server_name subdomain.example.com;
    server_tokens off; 
    root /opt/gitlab/embedded/service/gitlab-rails/public;

    client_max_body_size 250m;

    access_log  /var/log/nginx/gitlab_access.log;
    error_log   /var/log/nginx/gitlab_error.log;

    location / {
        proxy_redirect off;
        proxy_set_header Host $http_host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_pass http://gitlab;
    }
}

Nginx 访问日志

172.217.26.206 - - [21/Oct/2017:00:50:37 +0000] "GET / HTTP/1.1" 302 100 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36"
172.217.26.206 - - [21/Oct/2017:00:56:40 +0000] "GET / HTTP/1.1" 302 100 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36"
172.217.26.206 - - [21/Oct/2017:00:57:53 +0000] "GET / HTTP/1.1" 302 100 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36"

这个配置有什么问题?

答案1

这可能是因为配置文件没有被 nginx 读取。重新加载或重启 nginx 即可让 nginx 读取配置文件。

相关内容