我正试图从我的aws-lightsail公共IP托管我的Django应用程序。我已将我的应用程序部署到文件夹:/opt/bitnami/projects/spirit/spirit。并在/etc/apache2/sites-available/spirit-vhosts.conf中定义并激活了虚拟主机。我的spirit-vhosts.conf文件是:
<IfDefine !IS_spirit_LOADED>
Define IS_spirit_LOADED
WSGIDaemonProcess sample python-home=/opt/bitnami/python python-path=/opt/bitnami/projects/spirit processes=2 threads=1
5
</IfDefine>
<VirtualHost 127.0.0.1:80 _default_:80>
ServerAlias *
WSGIProcessGroup spirit
Alias /robots.txt /opt/bitnami/projects/spirit/static/robots.txt
Alias /favicon.ico /opt/bitnami/projects/spirit/static/favicon.ico
Alias /static/ /opt/bitnami/projects/spirit/static/
<Directory /opt/bitnami/projects/spirit/static>
Require all granted
</Directory>
Alias /media/ /opt/bitnami/projects/spirit/media/
<Directory /opt/bitnami/projects/spirit/media>
Require all granted
</Directory>
WSGIScriptAlias / /opt/bitnami/projects/spirit/spirit/wsgi.py
<Directory /opt/bitnami/projects/spirit/spirit>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
</VirtualHost>
但是,我无法从公共IP访问我的网站。我还在aws lightsail网络规则中添加了8000端口作为自定义TCP。当我执行sudo wget 127.0.0.1:80
时,我确实在html文件中得到了正确的响应。我错过了什么?
您尝试连接的IP是本地主机,而不是公共的。当你在AWS控制台中创建实例时,你会看到一个可以连接的公共dns名称。