如何配置 apache 在同一台机器上使用 FE 和 BE?

How to configure apache to work with FE and BE on same machine?

我需要配置一个 apache 服务器来为同一台机器的前端和后端(都 php)提供服务。 以下是考虑:

我当前的配置如下所示:

    NameVirtualHost *:80
    NameVirtualHost *:81


        ServerName www.myServer.de

        ServerAdmin webmaster@localhost
        DocumentRoot /data/fe/public

        
                Options FollowSymLinks
                AllowOverride None
                Order Deny,Allow
                Deny from All
        
        
                Options  FollowSymLinks
                AllowOverride AuthConfig
                Order allow,deny
                allow from all

                RewriteEngine On

            # Redirect Trailing Slashes...
            RewriteRule ^(.*)/$ / [L,R=301]

            # Handle Front Controller...
                RewriteCond %{REQUEST_FILENAME} !-d
                RewriteCond %{REQUEST_FILENAME} !-f
 RewriteRule ^ index.php [L]
        

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
        

        ErrorLog ${APACHE_LOG_DIR}/error_fe.log
        CustomLog ${APACHE_LOG_DIR}/access_fe.log combined



ServerAdmin webmaster@localhost
        DocumentRoot  /data/be/public

        
                Options FollowSymLinks
                AllowOverride None
                Order Deny,Allow
                Deny from All
        
        
                Options  FollowSymLinks
                AllowOverride AuthConfig
                Order allow,deny
                allow from all

                RewriteEngine On

            # Redirect Trailing Slashes...
            RewriteRule ^(.*)/$ / [L,R=301]

            # Handle Front Controller...
                RewriteCond %{REQUEST_FILENAME} !-d
                RewriteCond %{REQUEST_FILENAME} !-f
                RewriteRule ^ index.php [L]
    

        ErrorLog ${APACHE_LOG_DIR}/error_be.log
        CustomLog ${APACHE_LOG_DIR}/access_be.log combined

如何配置后端以在没有访问限制的情况下提供静态内容,同时保证 API 的安全。还是通过应用程序提供静态内容的替代方法?

我正在使用

我最终配置了一个反向代理来传送静态内容。我在我的前端虚拟主机中添加了以下几行:

ProxyPreserveHost On

ProxyPass /images http://<BE-IP>:81/files/images
ProxyPassReverse /images http://<BE-IP>:81/files/images

使用此配置,后端仍受防火墙保护免受外部请求,但允许 FE 请求图像。