Apache 多端口 HTTPS
Apache multiple ports HTTPS
我的配置
- 使用 Bitnami 的 AWS Lightsail
- 在端口 3000
上反应 运行
- 在端口 3001
上表达 运行
- 使用 Bitnami 脚本的 HTTPS(使用 Let's encrypt)
我想要什么
- 来自 https://www.ipos.fun/ or https://ipos.fun/ or ipos.fun/ or www.ipos.fun/ to go to https://www.ipos.fun/ 的任何电话。 (添加 wwww + https)
- My Express API 在端口 3001 上也可以使用 HTTPS。
当前工作
- 所有前端重定向工作正常。
什么不起作用
- 我的 Express API 通过 HTTP 工作,但当我尝试访问 https://www.ipos.fun:3001/.
时出现错误 www.ipos.fun unexpectedly closed the connection.
我试过的
请在下面找到我所有的配置,但我认为重要的一点是:
ProxyPass / http://localhost:3000/
ProxyPassReverse / http://localhost:3000/
我想根据端口号进行匹配,但似乎没有任何效果。
我还尝试了以下 url https://www.ipos.fun:3001/api/
ProxyPass /api http://localhost:3001/
ProxyPassReverse /api http://localhost:3001/
我尝试创建多个 VirtualHost
来对端口号进行模式匹配,但它不起作用。
问题
如何使端口 3001 上的 Express API 与 HTTPS 兼容?
这是我的配置:
# Default Virtual Host configuration.
<IfVersion < 2.3 >
NameVirtualHost *:80
NameVirtualHost *:443
</IfVersion>
<VirtualHost _default_:80>
DocumentRoot "/opt/bitnami/apache2/htdocs"
RewriteEngine On
# BEGIN: Enable HTTP to HTTPS redirection
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} !^(localhost|127.0.0.1)
RewriteCond %{REQUEST_URI} !^/\.well-known
RewriteRule ^/(.*) https://%{SERVER_NAME}/ [R,L]
# END: Enable HTTP to HTTPS redirection
# BEGIN: Enable non-www to www redirection
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} !^(localhost|127.0.0.1)
RewriteCond %{REQUEST_URI} !^/\.well-known
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=permanent,L]
# END: Enable non-www to www redirection
<Directory "/opt/bitnami/apache2/htdocs">
Options Indexes FollowSymLinks
AllowOverride All
<IfVersion < 2.3 >
Order allow,deny
Allow from all
</IfVersion>
<IfVersion >= 2.3 >
Require all granted
</IfVersion>
</Directory>
# Error Documents
ErrorDocument 503 /503.html
# Bitnami applications installed with a prefix URL (default)
Include "/opt/bitnami/apache2/conf/bitnami/bitnami-apps-prefix.conf"
</VirtualHost>
# Default SSL Virtual Host configuration.
<IfModule !ssl_module>
LoadModule ssl_module modules/mod_ssl.so
</IfModule>
Listen 443
SSLProtocol all -SSLv2 -SSLv3
SSLHonorCipherOrder on
SSLCipherSuite "..."
SSLPassPhraseDialog builtin
SSLSessionCache "shmcb:/opt/bitnami/apache2/logs/ssl_scache(512000)"
SSLSessionCacheTimeout 300
<VirtualHost _default_:443>
DocumentRoot "/opt/bitnami/apache2/htdocs"
RewriteEngine On
# BEGIN: Enable non-www to www redirection
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} !^(localhost|127.0.0.1)
RewriteCond %{REQUEST_URI} !^/\.well-known
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [R=permanent,L]
# END: Enable non-www to www redirection
SSLEngine on
SSLCertificateFile "/opt/bitnami/apache2/conf/ipos.fun.crt"
SSLCertificateKeyFile "/opt/bitnami/apache2/conf/ipos.fun.key"
<Directory "/opt/bitnami/apache2/htdocs">
Options Indexes FollowSymLinks
AllowOverride All
<IfVersion < 2.3 >
Order allow,deny
Allow from all
</IfVersion>
<IfVersion >= 2.3 >
Require all granted
</IfVersion>
</Directory>
ProxyRequests off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass / http://localhost:3000/
ProxyPassReverse / http://localhost:3000/
# Error Documents
ErrorDocument 503 /503.html
# Bitnami applications installed with a prefix URL (default)
Include "/opt/bitnami/apache2/conf/bitnami/bitnami-apps-prefix.conf"
</VirtualHost>
# Bitnami applications that uses virtual host configuration
Include "/opt/bitnami/apache2/conf/bitnami/bitnami-apps-vhosts.conf"
一种解决方案是在VirtualHost中添加路由:443,
ProxyPass /api/ http://localhost:3001/
ProxyPassReverse /api/ http://localhost:3001/
这就是我之前提到的,我只是在端口 3001 而不是端口 HTTPS 443 上进行测试。
我的配置
- 使用 Bitnami 的 AWS Lightsail
- 在端口 3000 上反应 运行
- 在端口 3001 上表达 运行
- 使用 Bitnami 脚本的 HTTPS(使用 Let's encrypt)
我想要什么
- 来自 https://www.ipos.fun/ or https://ipos.fun/ or ipos.fun/ or www.ipos.fun/ to go to https://www.ipos.fun/ 的任何电话。 (添加 wwww + https)
- My Express API 在端口 3001 上也可以使用 HTTPS。
当前工作
- 所有前端重定向工作正常。
什么不起作用
- 我的 Express API 通过 HTTP 工作,但当我尝试访问 https://www.ipos.fun:3001/. 时出现错误
www.ipos.fun unexpectedly closed the connection.
我试过的
请在下面找到我所有的配置,但我认为重要的一点是:
ProxyPass / http://localhost:3000/
ProxyPassReverse / http://localhost:3000/
我想根据端口号进行匹配,但似乎没有任何效果。 我还尝试了以下 url https://www.ipos.fun:3001/api/
ProxyPass /api http://localhost:3001/
ProxyPassReverse /api http://localhost:3001/
我尝试创建多个 VirtualHost
来对端口号进行模式匹配,但它不起作用。
问题
如何使端口 3001 上的 Express API 与 HTTPS 兼容?
这是我的配置:
# Default Virtual Host configuration.
<IfVersion < 2.3 >
NameVirtualHost *:80
NameVirtualHost *:443
</IfVersion>
<VirtualHost _default_:80>
DocumentRoot "/opt/bitnami/apache2/htdocs"
RewriteEngine On
# BEGIN: Enable HTTP to HTTPS redirection
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} !^(localhost|127.0.0.1)
RewriteCond %{REQUEST_URI} !^/\.well-known
RewriteRule ^/(.*) https://%{SERVER_NAME}/ [R,L]
# END: Enable HTTP to HTTPS redirection
# BEGIN: Enable non-www to www redirection
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} !^(localhost|127.0.0.1)
RewriteCond %{REQUEST_URI} !^/\.well-known
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=permanent,L]
# END: Enable non-www to www redirection
<Directory "/opt/bitnami/apache2/htdocs">
Options Indexes FollowSymLinks
AllowOverride All
<IfVersion < 2.3 >
Order allow,deny
Allow from all
</IfVersion>
<IfVersion >= 2.3 >
Require all granted
</IfVersion>
</Directory>
# Error Documents
ErrorDocument 503 /503.html
# Bitnami applications installed with a prefix URL (default)
Include "/opt/bitnami/apache2/conf/bitnami/bitnami-apps-prefix.conf"
</VirtualHost>
# Default SSL Virtual Host configuration.
<IfModule !ssl_module>
LoadModule ssl_module modules/mod_ssl.so
</IfModule>
Listen 443
SSLProtocol all -SSLv2 -SSLv3
SSLHonorCipherOrder on
SSLCipherSuite "..."
SSLPassPhraseDialog builtin
SSLSessionCache "shmcb:/opt/bitnami/apache2/logs/ssl_scache(512000)"
SSLSessionCacheTimeout 300
<VirtualHost _default_:443>
DocumentRoot "/opt/bitnami/apache2/htdocs"
RewriteEngine On
# BEGIN: Enable non-www to www redirection
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} !^(localhost|127.0.0.1)
RewriteCond %{REQUEST_URI} !^/\.well-known
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [R=permanent,L]
# END: Enable non-www to www redirection
SSLEngine on
SSLCertificateFile "/opt/bitnami/apache2/conf/ipos.fun.crt"
SSLCertificateKeyFile "/opt/bitnami/apache2/conf/ipos.fun.key"
<Directory "/opt/bitnami/apache2/htdocs">
Options Indexes FollowSymLinks
AllowOverride All
<IfVersion < 2.3 >
Order allow,deny
Allow from all
</IfVersion>
<IfVersion >= 2.3 >
Require all granted
</IfVersion>
</Directory>
ProxyRequests off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass / http://localhost:3000/
ProxyPassReverse / http://localhost:3000/
# Error Documents
ErrorDocument 503 /503.html
# Bitnami applications installed with a prefix URL (default)
Include "/opt/bitnami/apache2/conf/bitnami/bitnami-apps-prefix.conf"
</VirtualHost>
# Bitnami applications that uses virtual host configuration
Include "/opt/bitnami/apache2/conf/bitnami/bitnami-apps-vhosts.conf"
一种解决方案是在VirtualHost中添加路由:443,
ProxyPass /api/ http://localhost:3001/
ProxyPassReverse /api/ http://localhost:3001/
这就是我之前提到的,我只是在端口 3001 而不是端口 HTTPS 443 上进行测试。