简体   繁体   中英

How to use same port for http and https

I pretty much don't know about http and this topic, so couldn't find any answer enough to solve my question. Let me know if this question is duplicated and you already found the answer about this.

What I want to achieve

Normally it's working with http://domain:3000 but I want to make it accessible for https://domain:3000 .

What I did

I installed let's encrypt and added reverse proxy settings on my apache setting file. So it was possible to access https://domain:3000 with the path such as https://domain/api but as I mentioned above I want to directly use port number on https as well.

additional lines on my httpd.conf are

NameVirtualHost *:80
<VirtualHost *:80>
     ServerName my.domain
     ServerAlias www.my.domain *.my.domain
     DocumentRoot /var/www/html
     RewriteEngine on
     RewriteCond %{SERVER_NAME} =my.domain [OR]
     RewriteCond %{SERVER_NAME} =www.my.domain [OR]
     RewriteCond %{SERVER_NAME} =*.my.domain
     RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
<IfModule mod_ssl.c>
     Listen 443
</IfModule>
Include /etc/httpd/conf/httpd-le-ssl.conf

<IfModule mod_proxy.c>
    ProxyRequests Off
    ProxyPreserveHost On
    ProxyPass /api http://my.domain:3000
    ProxyPassReverse /api http://my.domain:3000
</IfModule>

Do I need to add more settings? or any other way to solve this?

最好配置必须使用其他端口进行SSL连接的应用程序,例如3001并通过HTTPS将请求转发到该端口或直接访问它

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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