简体   繁体   English

使用标准端口在 Apache 和 Apache tomcat 之间共享 SSL

[英]SSL sharing between Apache and Apache tomcat with standard port

I have a wordpress application deployed on an Apache server running on port 80 and I also have a java web application deployed on a Tomact server running on port 443.我在端口 80 上运行的 Apache 服务器上部署了一个 wordpress 应用程序,我还在端口 443 上运行的 Tomact 服务器上部署了一个 java web 应用程序。

So basically I have:所以基本上我有:

http ://mysite.com (Apache) http://mysite.com (Apache)

https: //mysite.com/application (Tomcat) https://mysite.com/application (Tomcat)

Now I need to start using my SSL certificate for my website.现在我需要开始为我的网站使用我的 SSL 证书。 I know that these processes cannot share the same port.我知道这些进程不能共享同一个端口。 Is there a way to keep both urls without adding an extra port?有没有办法在不添加额外端口的情况下保留两个网址? So both can be accessed via:所以两者都可以通过以下方式访问:

https ://mysite.com (Apache) https://mysite.com (Apache)

https ://mysite.com/application (Tomcat) https://mysite.com/application (Tomcat)

I'm basing this answer on my configuration with Apache in the front of a Tomcat instance.我将这个答案基于我在 Tomcat 实例前面使用 Apache 的配置。 I don't have your exact configuration but I believe the following should work.我没有你的确切配置,但我相信以下应该有效。

I have an SSL configuration which is where things get forwarded to Tomcat.我有一个 SSL 配置,它是将事情转发到 Tomcat 的地方。 I've modified it to be what I think you need:我已将其修改为我认为您需要的内容:

<VirtualHost _default_:443>
    ServerName www.example.com

    ProxyPreserveHost on
    ProxyPass /application http://localhost:8080/application
    ProxyTimeout 360

    # rest of the ssl configuration
</VirtualHost>

This should forward everything under /application to Tomcat and keep the rest being served by Apache.这应该将/application下的所有内容转发到 Tomcat,并让其余部分由 Apache 提供服务。 Note that this assumes that you have the proxy (aka mod_proxy) module enabled for your server.请注意,这假设您为服务器启用了proxy (又名 mod_proxy)模块。

An easy way of doing this is to mount an Nginx server and manage the redirection according to the URL hit:一个简单的方法是挂载一个 Nginx 服务器并根据 URL 命中管理重定向:

server {
    listen 80;
    server_name *.domain.me;
    location / {
        return 301 https://$host$request_uri;
    }
}
server {
    listen 443 ssl;
    server_name *.domain.me;

    ssl_certificate /path/to/crt;
    ssl_certificate_key /path/to/key;


    location / {
        proxy_pass http://destinationIp:destinationPort;
        proxy_set_header Host $host;
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM