nginx 代理非标准端口tomcat https

编程教程 > nginx (1353) 2024-11-26 14:39:04

前置说明,项目配置了个全局PATH,估计是为了方便复杂环境单容器多项目部署用的老项目配置方式

var PATH = [[${#httpServletRequest.getScheme() + "://" + #httpServletRequest.getServerName() + ":" + #httpServletRequest.getServerPort() + #httpServletRequest.getContextPath()}]];

导致普通的网上找的总是缺1或缺2的感觉,下面是整合好的一份配置说明

nginx 配置

server {
        listen 8100 ssl;
        server_name xxx.top;
        #ssl on;
        #从腾讯云获取到的第一个文件的全路径
        ssl_certificate /opt/docker/acme.sh/out/issue/xxx.pem;
        #从腾讯云获取到的第二个文件的全路径
        ssl_certificate_key /opt/docker/acme.sh/out/issue/xx.key.pem;

    location / {
                #proxy_set_header       Host $host;
                #非标准端口下面这个配置很重要
                proxy_set_header Host $host:$server_port;
                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  $scheme;
                #非标准端口下面这个配置很重要
                proxy_set_header X-Forwarded-Port $server_port;

                proxy_pass http://192.168.0.151:8100;
        }

}


spring boot 项目tomcat配置

server:
    # 配置项目端口
    port: 8000
    tomcat:
        remoteip:
            protocol-header: X-Forwarded-Proto
            remote-ip-header: X-Forwarded-For
            protocol-header-https-value: https


主要的是remoteip 节点下面的这三个必须配置

如果tomcat是独立部署的,则修改tomcat的配置文件Engne以下片段

<Valve className="org.apache.catalina.valves.RemoteIpValve"
                remoteIpHeader="x-forwarded-for"
                remoteIpProxiesHeader="x-forwarded-by"
                protocolHeader="x-forwarded-proto"
                protocolHeaderHttpsValue="https"
                httpsServerPort="8443"/>

 

 

 


 

 

 

 


评论
User Image
提示:请评论与当前内容相关的回复,广告、推广或无关内容将被删除。

相关文章
前置说明,项目配置了个全局PATH,估计是为了方便复杂环境单容器多项目部署用的老项目配置方式var PATH = [[${#httpServletRequest.getScheme() + ":...
nginx常规使用时作为http协议的反向代理,这里要讲的是非http的Mysql端口代理,理论支持其他协议nginx.conf配置如下:user nginx; worker_process...
最终看起来像这样 nginx (host,ssl) -&gtl; harbor-nginx (non-ssl) -&gtl; harbor。说明首先服务上安装有 nginx,且
tomcat如何配置SSL或者说HTTPS,tomcat,https,SSL。为何需要使用SSL
HTTP协议2.0,HTTP 2.0如何升级_HTTP2.0新特性_HTTP2.0详解。
nginx代理Tomcat带路径的项目location / {                 proxy_pass http://localhost:8080/v1/;          ...
前言本文主要讲述HTTPS协议如何保证安全或者说什么是HTTPS协议。近年来,随着用户和互联网企业安全意识的提高和 HTTPS 成本的下降,HTTPS 已经越来
问题描述最近网站被运营商劫持很严重,忍受不了,全站上了HTTPS
Nginx 安装Nginx 安装参考:Linux yum nginx安装和nginx入门配置方法-XQLEE'BlogAlpine Linux nginx安装配
环境说明 两个主机两个域名通过cname方式共用同一个cdn服务商,其中cdn.b.com是对应的cdn服务商
问题描述之前使用shiro时候遇到没有登录HTTPS被跳转到了HTTP,导致使用问题。之前通过nginx方式解决,参考:Shiro Https 跳转Http问题
PVE配置nginx代理访问。nginx配置:server { listen 10101 ssl; server_name pve.ok.top; #ssl on; #从腾...
idea maven https私服下载报错解决idea 打开设置菜单,找到setting-&gtl;Build,Excution,Deployment-&gtl;Build Tools&gtl...
在这个Spring Boot示例中,学习将 Web 应用程序配置为使用自签名证书在 SSL (HTTPS) 上运行
MIME 参考手册/HTTP文件上传格式过滤 类型/子类型扩展名application/envoyevyapplication/fractalsfifappli