在Nginx反向代理上为GitLab配置SSL

我在个人gitlab设置中遇到了一个小问题.我想重定向从http://gitlab.example.com到https://gitlab.example.com的所有流量.SSL确实在https://gitlab.example.com上运行,但必须专门打字.下面是我的nginx conf文件.server { listen 192.168.1.13

我在个人gitlab设置中遇到了一个小问题.我想重定向从http://gitlab.example.com到https://gitlab.example.com的所有流量.SSL确实在https://gitlab.example.com上运行,但必须专门打字.下面是我的nginx conf文件.

server {
    listen 192.168.1.139:443;
    server_name gitlab.example.com;

    listen 443;
    ssl on;
    ssl_certificate /etc/nginx/ssl/gitlab.crt;
    ssl_certificate_key /etc/nginx/ssl/gitlab.key;


location / {
    proxy_pass http://192.168.1.139:80;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header x-Forwarded-For $proxy_add_x_forwarded_for;
   }
}

GitLab安装是一个综合安装.我在配置文件中更改了什么以允许ssl重定向?
最佳答案
有两个选项:重写和HTTP 301永久重定向,第二个是更优选:

server {
       listen         80;
       server_name    _;
       return         301 https://$server_name$request_uri;
}

作者: dawei

【声明】:滨州站长网内容转载自互联网,其相关言论仅代表作者个人观点绝非权威,不代表本站立场。如您发现内容存在版权问题,请提交相关链接至邮箱:bqsm@foxmail.com,我们将及时予以处理。

为您推荐

联系我们

联系我们

0577-28828765

在线咨询: QQ交谈

邮箱: xwei067@foxmail.com

工作时间:周一至周五,9:00-17:30,节假日休息

返回顶部