Virtualhost

使用代理位置修復 Apache Virtualhost

  • March 5, 2015

給定以下虛擬主機:

<VirtualHost *:80>
   DocumentRoot "/var/www/dashboards/public/dist"
   Servername local.dashboards
   ServerAlias local.dashboards

   Header add Access-Control-Allow-Origin: "*"
   Header add Access-Control-Allow-Methods: "POST, GET, OPTIONS, PUT, DELETE, HEAD"
   Header set Access-Control-Allow-Headers: "Origin, X-Requested-With, Content-Type, Accept, Authorization"

   Alias /api /var/www/dashboards/laravel/public

   <Directory "/var/www/dashboards/public/dist">
       Options MultiViews FollowSymLinks
       AllowOverride All
       Order allow,deny
       Allow from all
   </Directory>

   <Directory "/var/www/dashboards/laravel/public">
       Options MultiViews FollowSymLinks
       AllowOverride All
       Order allow,deny
       Allow from all
   </Directory>

   <Location />
       ProxyPass http://localhost:3030/
       ProxyPassReverse http://localhost:3030/
   </Location>

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

</VirtualHost>

ahone 可以建議為什麼對 local.dashboards/api 的請求仍然被 Location 指令擷取嗎?我可以確認節點伺服器正在擷取對 /api 的請求並返回 404 頁面。

文件

別名發生在<Directory>檢查節之前,因此只有別名的目的地受到影響。(但請注意<Location>,在執行別名之前,部分會執行一次,因此它們將適用。)

A<Location />幾乎適用於一切。

怎麼樣<LocationMatch !^/api>呢?

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