node.js - 如何配置 apache 将 https 请求转发到在端口 1337 上运行的 Strapi/node 应用程序?
问题描述
我有一个 Strapi/node js 应用程序在端口 1337 上运行,我可以通过以下方式访问它:
http://my-ip:1337
我还在同一服务器中关联了一个域,并在 apache2 中有一个有效的 ssl 证书,因此在浏览器中我可以使用 https:
现在,当我尝试使用 https 访问端口 1337 时,如下所示:
我收到“此站点无法提供安全连接”错误。
我尝试使用以下代码在 apache 2 中编辑 my-domain.ssl.conf:
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName www.my-domain
ServerAlias my-domain
DocumentRoot /var/www/my-domain/public_html
ErrorLog /var/www/my-domain/log/error.log
CustomLog /var/www/my-domain/log/requests.log combined
SSLProxyEngine On
ProxyPreserveHost On
ProxyPass / http://localhost:1337/
ProxyPassReverse / http://localhost:1337/
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/my-domain/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/my-domain/privkey.pem
</VirtualHost>
</IfModule>
但不幸的是,当我引入 ProxyPass 指令时,服务器停止工作而没有任何有意义的错误。mod_proxy 和 mod_proxy_http 都加载在 apache2 配置中。
这里可能是什么问题?感谢任何可以帮助它的人!
解决方案
Strapi/node js 应用程序在端口 1337 上运行到 https
第一次变化
编辑 /etc/apache2/sites-available/000-default.conf
ServerName yourdomian-name.com
ProxyPreserveHost On
SSLProxyEngine On
ProxyPass / http://localhost:1337/
ProxyPassReverse / http://localhost:1337/
ProxyPreserveHost On
SSLCertificateFile /etc/letsencrypt/live/yourdomian-name.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/yourdomian-name.com/privkey.pem
第二次改变
编辑这个 /etc/apache2/sites-available/000-default-le-ssl.conf
SSLCertificateFile /etc/letsencrypt/live/yourdomian-name.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/yourdomian-name.com/privkey.pem
ServerName yourdomian-name.com
ProxyPreserveHost On
SSLProxyEngine On
ProxyPass / http://localhost:1337/
ProxyPassReverse / http://localhost:1337/
ProxyPreserveHost On
然后重启apache2
须藤 /etc/init.d/apache2 重启
推荐阅读
- python - 如何在 celery Prefork 中并行运行比 CPU 数量更多的轮询进程/任务
- c# - 从次要形式恢复形式
- haproxy - haproxy 限制对特定 IP 范围的根路径的访问,但允许从任何地方访问特定子目录
- wpf - 使用 .Net 6 WPF 应用程序的 VS2022 单个 exe 文件部署不起作用
- javascript - 在 javascript 中配对多个图像(每个图像有多个选项)
- javascript - 设置承载令牌
- python - 在opencv中创建具有特定图案的随机形状图像?
- asp.net-mvc - ASP.NET MVC 在 Azure Kudu 部署期间运行 Gruntfile.js 作为构建的一部分
- gif - 如何制作这样的人脸动态gif
- generics - 为所有使用 const 参数实现特征的类型实现特征