当前位置: 移动技术网 > 网络运营>服务器>nginx > Nexus使用nginx代理实现支持HTTPS协议

Nexus使用nginx代理实现支持HTTPS协议

2020年06月22日  | 移动技术网网络运营  | 我要评论

背景

公司全部网站需要支持 https 协议,在阿里云负载均衡配置 ssl 证书后,导致 nexus 的 https 访问出错。

网站访问路径: 域名解析到阿里云的负载均衡,负载均衡配置 80 端口强转 443 端口,443 端口配置 ssl 证书,并转发到内网 nginx,内网的 nginx 再代理 nexus 服务。

解决

浏览器 https 访问 nexus 的 console 报错信息:

报错信息大致意思是:https 访问的页面上不允许出现 http 请求。

解决方法: 在 nginx 配置文件增加 “proxy_set_header x-forwarded-proto https;” ,这样 nginx 在转发时就使用 https 协议。

nginx.conf 中的 nexus 配置内容:

location ^~ /nexus {

    proxy_pass http://x.x.x.x:8080/nexus;

    sendfile 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_set_header  x-forwarded-proto https; # 转发时使用https协议
    proxy_max_temp_file_size 0;

    # this is the maximum upload size
    client_max_body_size    20m;
    client_body_buffer_size  128k;

    proxy_connect_timeout   90;
    proxy_send_timeout     90;
    proxy_read_timeout     90;

    proxy_temp_file_write_size 64k;

    # required for new http-based cli
    proxy_http_version 1.1;
    proxy_request_buffering off;
    proxy_buffering off; # required for http-based cli to work over ssl
  }

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持移动技术网。

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网