how can I run 2 sites, one requires reverse proxy, other is just a normal website.

May 12, 2018 472 views
Apache Ubuntu

The .NET core API requires apache set up as reverse proxy.
How can I run both the web API and my other normal web site that doesn't require any reverse proxy stuff.

1 comment
  • one site is a .net core web API, which requires me to set up reverse proxy to run it.
    my other site is a laravel web site.
    I want to run both on same server. I know about using virtual hosts but what about where 1 is reverse proxy and other is not?

1 Answer

@bjm3819

You need to use a different apache configuration file for each one of them.

I will assume that you have webapi.net DNS record for the .net core web API and laravel-app.com DNS record for the laravel application, here is an example config for each one of them.

The first one webapi.conf

<VirtualHost *:80>
ServerName webapi.net

ErrorLog ${APACHE_LOG_DIR}/net_error.log
CustomLog ${APACHE_LOG_DIR}/net_access.log combined
ProxyPassReverse "/" <url to net core api with / at the end>

</VirtualHost>

The second one laravel-app.conf

ServerName laravel-app.com
DocumentRoot (path to local laravel application)

<Directory (path to local laravel application)>
       AllowOverride All
</Directory>
ErrorLog ${APACHE_LOG_DIR}/laravel_error.log
CustomLog ${APACHE_LOG_DIR}/laravel_access.log combined

Enable the two new sites

sudo a2ensite webapi.conf
sudo a2ensite laravel-app.com
sudo service apache2 restart

Now you can access the net core API with this url http://webapi.net and the laravel application with this url http://laravel-app.com.

Have another answer? Share your knowledge.