加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 运营中心 > Nginx > 正文

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

发布时间:2020-12-13 21:22:14 所属栏目:Nginx 来源:网络整理
导读:我在个人gitlab设置中遇到了一个小问题.我想重定向从http://gitlab.example.com到https://gitlab.example.com的所有流量.SSL确实在https://gitlab.example.com上运行,但必须专门打字.下面是我的nginx conf文件. server { listen 192.168.1.139:443; server_n

我在个人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;
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读