如何解决localhost:8443在我的本地Tomcat中使用“https://mydev.example”之类的别名

问题描述 投票:0回答:2

我已经在本地Tomcat的端口8443上成功设置了SSL,并且我在本地生成了用于开发目的的证书。它工作正常。

在我的/etc/hosts文件中,我有条目:

127.0.0.1  mydev.example  mydevsecure.example

我可以通过输入来访问我的应用程序:https://mydevsecure.example:8443/myApp/myPage.jsp [https]或http://mydev.example/myApp/myPage.jsp [http]

我想要的是能够输入:https://mydevsecure.example/myApp/myPage.jsp

我想在浏览器中输入端口号8443。

我无法在/ etc / hosts文件中指定我知道的端口号。

还有哪些其他解决方案?

ssl tomcat https dns hostname
2个回答
0
投票

qazxsw poi的默认端口是qazxsw poi。在您的浏览器中键入qazxsw poi,它将(尝试)连接到默认的https端口443

因此,您只需编辑Apache Tomcat的https://mydevsecure.example/myApp/myPage.jsp文件并找到SSL连接器。然后将端口https更改为443并重新启动Apache Tomcat。

编辑:

如果您的Tomcat无法绑定端口443,因为它不是以root身份运行,则有多种替代方法:

  • 使用server.xml允许Tomcat绑定端口443
  • 使用8443方法允许tomcat绑定到端口443。
  • 以root身份运行Tomcat(不好主意......)
  • 将端口更改回8443并拥有转发器443

0
投票

我通过以下方法解决了这个问题:

Create self signed SSL certificate

运行OpenSSL命令以生成您的私钥和公共证书。回答问题并根据提示设置密码。

JSCV

Install Apache

other advanced unix

Add SSL config in /etc/httpd/conf/httpd.conf

redirect requests incoming on port 443 to 8443

Add the new secure URL alias in hosts file

127.0.0.1 mydev.example

Start Tomcat and Apache

我现在可以通过安全URL访问我的应用程序:

openssl req -newkey rsa:2048 -nodes -keyout mykey.pem -x509 -days 365 -out mycert.pem

© www.soinside.com 2019 - 2024. All rights reserved.