每个URL都被重定向到Gitlab页面

时间:2017-10-30 00:34:43

标签: python django nginx digital-ocean gitlab-ci

我想在数字海洋中拥有Gitlab CI和Django。我创建了一个Droplet并使用以下设置配置了Gitlab安装:

external_url = "http:/lab.###.com/"

# gitlab_rails['gitlab_email_from'] = "gitlab@example.com"
# gitlab_rails['gitlab_support_email'] = "support@example.com"

# gitlab_rails['smtp_enable'] = true
# gitlab_rails['smtp_address'] = "smtp.server"
# gitlab_rails['smtp_port'] = 465
# gitlab_rails['smtp_user_name'] = "smtp user"
# gitlab_rails['smtp_password'] = "smtp password"
# gitlab_rails['smtp_domain'] = "example.com"
# gitlab_rails['smtp_authentication'] = "login"
# gitlab_rails['smtp_enable_starttls_auto'] = true
# gitlab_rails['smtp_openssl_verify_mode'] = 'peer'

# nginx['redirect_http_to_https'] = false
# nginx['ssl_certificate'] = "/etc/gitlab/ssl/gitlab.crt"
# nginx['ssl_certificate_key'] = "/etc/gitlab/ssl/gitlab.key"

这是我的nginx设置

server {
    listen 80;
    server_name 150.200.##.## abc.com www.abc.com;
    client_max_body_size 50M;

    location = /favicon.ico { access_log off; log_not_found off; }
    location /static/ {
        root /home/root/eatplus-django;
    }

    location / {
        include proxy_params;
        proxy_pass         http://127.0.0.1:8000/;
        proxy_redirect     off;
        # proxy_set_header   Host             $host;
        proxy_set_header   X-Real-IP        $remote_addr;
        proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
        proxy_connect_timeout 30;
        proxy_read_timeout 30;
    }
}

当我进入实验室##。com时,我被重定向到Gitlab,这是预期的,但是当输入IP地址和www。###。com时,我仍然被重定向到Gitlab页面,这是意外的行为。我该如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

在您的nginx配置中,将server_name配置更改为

server_name lab.###.com;

通过这种方式,nginx将仅在lab.###.com子域名下为您的gitlab页面提供服务。