Categories: apache, configuration, server

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

1 answer

I need to configure an apache server to serve a frontend and a backend (both php) from the same machine. The following is to consider:

  • The backend is RESTful and the API is secured by the firewall allowing only localhost access (only as temporary solution till API tokens are implemented).
  • The frontend is on the same machine as backend at the moment, but will move to another server in some time.
  • Static content will be delivered from the backend machine

My current configuration looks like following:

     NameVirtualHost *:80     NameVirtualHost *:81           ServerName www.myServer.de          ServerAdmin [email protected]         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 ^(.*)/$ /$1 [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 [email protected]         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 ^(.*)/$ /$1 [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  

How can I configure the backend to serve static content without access limitation but keep the API secured. Or would it be an alternative to deliver static content through the application?

I'm using

  • Debian 8.1
  • Apache 2.4

All answers to this question, which has the identifier 33188639

The best answer:

I ended up with configuring a reverse proxy for delivering static content. I added the following lines to my frontend vhost:

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

With this configuration the backend is still guarded by the firewall from external requests but allows the FE to request images.

Last questions

how do i remove the switch on my home screen?
how to edit the JS date and time to update atuomatically?
How to utilize data stored in a multidimensional array
Powermockito not mocking URL constructor in URI.toURL() method
Android Bluetooth LE Scanner only scans when phone's Location is turned on in some devices
docker wordpress container can't connect to mysql container
How can I declare a number in java that is more than 64-bits? [duplicate]
Optaplanner solutionClass entityCollectionProperty should never return null error when simple JSON object passed to controller
Anylogic, get the time a pedestrain is in a queue
How do I fix this syntax issue with my .flex file?
Optimizing query in PHP
How to find the highest number of a column and print two columns of that row in R?
Ideas on “Error: Type com.google.firebase.iid.zzav is referenced as an interface from com.google.firebase.messaging.zzd”?
JCIFS SmbFile.exists() and SmbFile.isDirectory() return false when it exists and I can listFiles()
PHP total order
Laravel booking system design
neural net - undefined column selected
How to indicate y axis does not start from 0 in ggplot?
Fragments in backStack
Spinner how to change the data