How to configure apache with various virtualhost (nginx as a proxy server)?

1

Good, I have installed an ubuntu environment with local apache to use Apache as a reverse proxy of NGINX.

The idea is to serve the nginx requests on port 80 and run apache on port 8080, so far it works for me.

My structure where I have the files is in / var / www / html

Now what I'm trying to do is a virtualhost that when I put "localhost" it takes the root by default, that is, the directory "/ var / www / html" and a virtualhost that when I put "www.test.io" I go to the directory "/ var / www / html / portal", for that I have these configuration files:

File "test.io.conf" in / etc / apache2 / sites-available

<VirtualHost 127.0.0.1:8080>

ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/portal
ServerName test.io
ServerAlias www.test.io

<Directory /var/www/html/portal>
   AllowOverride All
</Directory>

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

#Include conf-available/serve-cgi-bin.conf

File "000-default.conf" in / etc / apache2 / sites-available

<VirtualHost 127.0.0.1:8080>

ServerAdmin webmaster@localhost
DocumentRoot /var/www/html

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

If with a browser I go to link I see that I go to the root where I have the documents "/ var / www / html /", but if in the browser I type the URL link or link what makes me the browser is to really go to that domain that exists on the internet and not the virtualhost that I created.

Thank you.

    
asked by ilernet 14.11.2017 в 15:31
source

2 answers

4

Enter the terminal (console) and enter:

  

sudo nano / etc / hosts

Inside the configuration file add the following parameter:

  

127.0.0.1 www.test.io

For the domain to point to the local IP address and thus be able to access the server.

    
answered by 20.11.2017 / 06:21
source
2

It looks like the hosts files are correct, you have not put anything on if you have enabled the VirtualHost files but if not, you should do it:

sudo a2ensite test.io.conf

After applying changes, restart the apache service

sudo service apache2 restart
    
answered by 19.11.2017 в 05:42