问题描述
我使用bitnami的节点映像在AWS Lightsail上创建一个实例.
我安装了我的应用程序并启动了它,并根据我发现的指南进行了配置,就像这样:
我检查了一下,看来 bitnami.conf
仍然包括我添加的 bitnami-apps-prefix.conf
我试图将代理添加为虚拟主机中的第一件事,但这无济于事.
这是我的/opt/bitnami/apache2/conf/bitnami/bitnami.conf
文件:
#默认虚拟主机配置.#让Apache知道我们在支持SSL反向代理SetEnvIf X-Forwarded-Proto https HTTPS = on< VirtualHost _default_:80>DocumentRoot"/opt/bitnami/apache/htdocs"#BEGIN:letsencrypt的配置包括"/opt/bitnami/apps/letsencrypt/conf/httpd-prefix.conf"#END:letsencrypt的配置#BEGIN:使用无位置的mod_proxy时支持域更新< IfModule mod_proxy.c>ProxyPass/.知名!</IfModule>#END:使用不带位置的mod_proxy时支持域更新#BEGIN:启用HTTP到HTTPS重定向RewriteEngine开RewriteCond%{HTTPS}!= onRewriteCond%{HTTP_HOST}!^ localhostRewriteCond%{HTTP_HOST}!^ [0-9] +.[0-9] +.[0-9] +.[0-9] +(:[0-9] +)?$RewriteCond%{REQUEST_URI}!^/\.众所周知RewriteRule ^/(.*)https://%{SERVER_NAME}/$ 1 [R,L]#END:启用HTTP到HTTPS重定向<目录"/opt/bitnami/apache/htdocs">选项索引FollowSymLinks允许全部覆盖要求所有授予</目录>#错误文件ErrorDocument 503/503.html#Bitnami应用程序安装了前缀URL(默认)包括"/opt/bitnami/apache2/conf/bitnami/bitnami-apps-prefix.conf"#BEGIN:在位置中使用mod_proxy时支持域更新<位置/.众所周知的>< IfModule mod_proxy.c>ProxyPass!</IfModule></位置>#END:在位置中使用mod_proxy时支持域更新</VirtualHost>包括"/opt/bitnami/apache/conf/bitnami/bitnami-ssl.conf"
我在这里想念什么?为什么请求没有重定向到我的应用程序?
此处是Bitnami工程师,
似乎您没有遵循Bitnami文档.如果您看一下它,可以通过不同的步骤在实例中配置VirtualHost.
您可以复制我们在实例中生成的文件
sudo cp/opt/bitnami/apache/conf/vhosts/sample-http-vhost.conf.disabled/opt/bitnami/apache/conf/vhosts/sample-http-vhost.confsudo cp/opt/bitnami/apache/conf/vhosts/sample-https-vhost.conf.disabled/opt/bitnami/apache/conf/vhosts/sample-https-vhost.conf
或生成具有以下内容的文件
- /opt/bitnami/apache/conf/vhosts/myapp-http-vhost.conf
< VirtualHost _default_:80>ServerAlias *DocumentRoot"/opt/bitnami/projects/myapp/public"<目录"/opt/bitnami/projects/myapp/public"要求所有授予</目录>ProxyPass/http://localhost:3000/ProxyPassReverse/http://localhost:3000/</VirtualHost>
- /opt/bitnami/apache/conf/vhosts/myapp-https-vhost.conf
< VirtualHost _default_:443>ServerAlias *启用SSLEngineSSLCertificateFile"/opt/bitnami/apache/conf/bitnami/certs/server.crt"SSLCertificateKeyFile"/opt/bitnami/apache/conf/bitnami/certs/server.key"DocumentRoot"/opt/bitnami/projects/myapp"<目录"/opt/bitnami/projects/myapp">要求所有授予</目录>ProxyPass/http://localhost:3000/ProxyPassReverse/http://localhost:3000/</VirtualHost>
您将需要稍后重新启动Apache
sudo/opt/bitnami/ctlscript.sh重新启动apache
I create an instance on AWS Lightsail with bitnami's node image.
I installed my app and started it, configured everything according to the guides I found, like this one: host public node js website on amazon AWS LightSail without Bitnami
For some reason I didn't have bitnami-apps-prefix.conf
so I created it and then included it in /opt/bitnami/apache2/conf/bitnami/bitnami.conf
.Restarted Apache, and it worked.
Afterward I installed ssl certificate with the provided bncert-tool. after the certificate as added my domain has ssl but I can no longer access my app, I get the default page, the same as I got right after the instance went up:
I checked and it seems that bitnami.conf
still includes my addtion of bitnami-apps-prefix.conf
I tried to add proxy as the first thing in the virtual host but it doesn't help.
Here is my /opt/bitnami/apache2/conf/bitnami/bitnami.conf
file:
# Default Virtual Host configuration.
# Let Apache know we're behind a SSL reverse proxy
SetEnvIf X-Forwarded-Proto https HTTPS=on
<VirtualHost _default_:80>
DocumentRoot "/opt/bitnami/apache/htdocs"
# BEGIN: Configuration for letsencrypt
Include "/opt/bitnami/apps/letsencrypt/conf/httpd-prefix.conf"
# END: Configuration for letsencrypt
# BEGIN: Support domain renewal when using mod_proxy without Location
<IfModule mod_proxy.c>
ProxyPass /.well-known !
</IfModule>
# END: Support domain renewal when using mod_proxy without Location
# BEGIN: Enable HTTP to HTTPS redirection
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} !^localhost
RewriteCond %{HTTP_HOST} !^[0-9]+.[0-9]+.[0-9]+.[0-9]+(:[0-9]+)?$
RewriteCond %{REQUEST_URI} !^/\.well-known
RewriteRule ^/(.*) https://%{SERVER_NAME}/$1 [R,L]
# END: Enable HTTP to HTTPS redirection
<Directory "/opt/bitnami/apache/htdocs">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</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"
# BEGIN: Support domain renewal when using mod_proxy within Location
<Location /.well-known>
<IfModule mod_proxy.c>
ProxyPass !
</IfModule>
</Location>
# END: Support domain renewal when using mod_proxy within Location
</VirtualHost>
Include "/opt/bitnami/apache/conf/bitnami/bitnami-ssl.conf"
What am I missing here? why requests are not redirected to my app?
Bitnami Engineer here,
It seems you didn't follow the Bitnami documentation. If you take a look at it, there are different steps to configure the VirtualHost in the instance.
You can either copy the file we generate in the instance
sudo cp /opt/bitnami/apache/conf/vhosts/sample-http-vhost.conf.disabled /opt/bitnami/apache/conf/vhosts/sample-http-vhost.conf
sudo cp /opt/bitnami/apache/conf/vhosts/sample-https-vhost.conf.disabled /opt/bitnami/apache/conf/vhosts/sample-https-vhost.conf
or generate those files with the following content
- /opt/bitnami/apache/conf/vhosts/myapp-http-vhost.conf
<VirtualHost _default_:80>
ServerAlias *
DocumentRoot "/opt/bitnami/projects/myapp/public"
<Directory "/opt/bitnami/projects/myapp/public">
Require all granted
</Directory>
ProxyPass / http://localhost:3000/
ProxyPassReverse / http://localhost:3000/
</VirtualHost>
- /opt/bitnami/apache/conf/vhosts/myapp-https-vhost.conf
<VirtualHost _default_:443>
ServerAlias *
SSLEngine on
SSLCertificateFile "/opt/bitnami/apache/conf/bitnami/certs/server.crt"
SSLCertificateKeyFile "/opt/bitnami/apache/conf/bitnami/certs/server.key"
DocumentRoot "/opt/bitnami/projects/myapp"
<Directory "/opt/bitnami/projects/myapp">
Require all granted
</Directory>
ProxyPass / http://localhost:3000/
ProxyPassReverse / http://localhost:3000/
</VirtualHost>
You will need to restart Apache later
sudo /opt/bitnami/ctlscript.sh restart apache
这篇关于ssl配置后,节点的Bitnami代理不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!