Ubuntu

如何在 UBUNTU 上為 .NET CORE 2.0 配置多個 Apache 子域?

  • December 10, 2018

我找到了這篇文章並更新了我的配置。

我在 Apache 上有這個反向代理配置。

<VirtualHost *:80>
   ServerName a123.com
   ServerAlias www.a123.com

   RewriteEngine On
   RewriteCond %{HTTPS} !=on
   RewriteRule ^/?(.*) https://%{SERVER_NAME}/ [R,L]
</VirtualHost>
<VirtualHost *:443>
   ProxyPreserveHost On
   ProxyPass "/test2/" "http://localhost:48630"
   ProxyPassReverse "/test2/" "http://localhost:48630"
   ProxyPass "/" "http://localhost:5000/"
   ProxyPassReverse "/" "http://localhost:5000/"
   ErrorLog /var/log/httpd/a123-error.log
   CustomLog /var/log/httpd/a123-access.log common
   SSLEngine on
   SSLCertificateFile /etc/ssl/certs/a123.com.crt
   SSLCertificateKeyFile /etc/ssl/private/a123.com.key
</VirtualHost>

應該如何更改此配置以訪問 www.a123.com 和 test2.a123.com 子域?

我現在只能用這個配置訪問 www.a123.comwww.a123.com/test2/ 嗎?

您可以為每個域編寫兩個 VirtualHost,並將它們傳遞到不同的位置。

編輯:2 個虛擬主機,沒有 SSL

編輯:DNS配置中必須允許所有子域為*

<VirtualHost *:80>
   ServerName a123.com
   ServerAlias www.a123.com
   ProxyPreserveHost On
   ProxyPass "/" "http://localhost:5000/"
   ProxyPassReverse "/" "http://localhost:5000/"
   ErrorLog /var/log/httpd/a123-error.log
   CustomLog /var/log/httpd/a123-access.log common
</VirtualHost>

<VirtualHost *:80>
   ServerName test2.a123.com
   ServerAlias www.test2.a123.com
   ProxyPreserveHost On
   ProxyPass "/" "http://localhost:48630/"
   ProxyPassReverse "/" "http://localhost:48630/"
   ErrorLog /var/log/httpd/test-a123-error.log
   CustomLog /var/log/httpd/test-a123-access.log common
</VirtualHost>

引用自:https://serverfault.com/questions/942587