在Apache中配置多个主机,并在不同端口上使用SSL配置多个主机

发布于 2025-01-23 02:50:51 字数 2784 浏览 1 评论 0原文

嗨,我想在不同端口上使用SSL上的同一服务器上运行多个站点,这是我到目前为止所做的。

default-ssl.conf

<IfModule mod_ssl.c>
<VirtualHost _default_:443>
    ServerAdmin [email protected]
    ServerName app.example.com
    DocumentRoot path_to_project_directory
    <Directory path_to_project_directory>
                Options -Indexes +FollowSymLinks +MultiViews
                AllowOverride All
                Require all granted
</Directory>


    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
    SSLEngine on
    SSLCertificateFile  /etc/ssl/certs/ssl-cert-snakeoil.pem
    SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key

</VirtualHost>
</IfModule>

带有上述配置,当我运行 https://aap.example 。 “ nofollow noreferrer”> https://app.example.com:8000 ,因此,为此,我制作了另一个虚拟主机文件。

app.example.com.conf

<VirtualHost *:8000>
    ServerAdmin [email protected]
    ServerName app.example.com
    Alias /static/ path_to_project_directory


    WSGIPassAuthorization On
    WSGIScriptAlias / path_to_project_directory/wsgi.py
    WSGIDaemonProcess example_wsgi33 processes=3 threads=15 display-name=example_wsgi33 python-path=path_to_project_directory:path_to_project_directory/venv/lib/python3.9/site-packages

    <Directory path_to_project_directory>
            WSGIProcessGroup example_wsgi33
            WSGIApplicationGroup %{GLOBAL}
            DirectoryIndex manage.py
            Require all granted
            Options -Indexes -MultiViews +SymLinksIfOwnerMatch
            Allow from all
    </Directory>

    <Directory path_to_project_directory>
            Require all granted
    </Directory>


    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    SSLEngine on
    SSLCertificateFile  /etc/ssl/certs/ssl-cert-snakeoil.pem
    SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key

但是当我尝试运行 https:/ /app.example.com:8000 它什么也没告诉我,我遇到的错误就像响应太久了。 任何人都知道如何在不同端口上运行站点。 这是我的端口

Listen 80
Listen 8000
Listen 8001
Listen 8002

<IfModule ssl_module>
    Listen 443
</IfModule>

<IfModule mod_gnutls.c>
    Listen 443
</IfModule>

Hi i want to run multiple sites on same server with ssl on different ports, here is what i did so far.

default-ssl.conf

<IfModule mod_ssl.c>
<VirtualHost _default_:443>
    ServerAdmin [email protected]
    ServerName app.example.com
    DocumentRoot path_to_project_directory
    <Directory path_to_project_directory>
                Options -Indexes +FollowSymLinks +MultiViews
                AllowOverride All
                Require all granted
</Directory>


    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
    SSLEngine on
    SSLCertificateFile  /etc/ssl/certs/ssl-cert-snakeoil.pem
    SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key

</VirtualHost>
</IfModule>

With above configuration when i run https://aap.example.com on browser it works fine now i want to run same domain on different port with ssl like https://app.example.com:8000, so for this i have made another virtual host file like this.

app.example.com.conf

<VirtualHost *:8000>
    ServerAdmin [email protected]
    ServerName app.example.com
    Alias /static/ path_to_project_directory


    WSGIPassAuthorization On
    WSGIScriptAlias / path_to_project_directory/wsgi.py
    WSGIDaemonProcess example_wsgi33 processes=3 threads=15 display-name=example_wsgi33 python-path=path_to_project_directory:path_to_project_directory/venv/lib/python3.9/site-packages

    <Directory path_to_project_directory>
            WSGIProcessGroup example_wsgi33
            WSGIApplicationGroup %{GLOBAL}
            DirectoryIndex manage.py
            Require all granted
            Options -Indexes -MultiViews +SymLinksIfOwnerMatch
            Allow from all
    </Directory>

    <Directory path_to_project_directory>
            Require all granted
    </Directory>


    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    SSLEngine on
    SSLCertificateFile  /etc/ssl/certs/ssl-cert-snakeoil.pem
    SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key

but when i try to run https://app.example.com:8000 it shows me nothing and i'm getting error like took too long to respond..
Anybody has idea how i can run site on different ports.
Here is my ports.conf

Listen 80
Listen 8000
Listen 8001
Listen 8002

<IfModule ssl_module>
    Listen 443
</IfModule>

<IfModule mod_gnutls.c>
    Listen 443
</IfModule>

I have already enabled these ports on my digital ocean firewall

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文