apache - 如何为 http 和 https 使用相同的端口
问题描述
我几乎不知道 http 和这个主题,所以找不到任何足以解决我的问题的答案。让我知道这个问题是否重复并且您已经找到了有关此问题的答案。
我想要达到的目标
通常它与http://domain:3000一起使用,但我想让它可以访问https://domain:3000。
我做了什么
我安装了 let's encrypt 并在我的 apache 设置文件中添加了反向代理设置。因此可以使用https: //domain/api等路径访问https://domain:3000 ,但正如我上面提到的,我也想直接在 https 上使用端口号。
我的 httpd.conf 上的其他行是
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>
我需要添加更多设置吗?或任何其他方式来解决这个问题?
解决方案
最好配置您必须使用不同端口进行 SSL 连接的应用程序,例如 3001 并通过 HTTPS 将请求转发到此端口或直接访问它
推荐阅读
- r - 在 ggpubr 中添加后层
- python - 如果数字增加 2,则数字 X 增加 1
- python - 如何在 FME 中添加 boto3 AWS S3 对象标签?
- google-bigquery - Google Bigquery java 客户端 listTables 将 numBytes 和 numRows 返回为 null
- json - JSON - 来自嵌套属性的架构全局依赖项
- java - 使用 JAVA (Android) 在 XML 中编辑自定义属性
- powershell - 我们如何将 azure 存储帐户表复制到另一个存储帐户?
- python - 如何在 PySpark 中使用 .contains() 按单个或多个子字符串进行过滤?
- deployment - 如何将我的服务从 alpha 移动到 sitetest3
- usb - BSR = 0 的地址设备命令的 USB 事务错误完成代码