Skip to content

Instantly share code, notes, and snippets.

@Fuhrmann
Forked from rdeavila/CONFIG.md
Created June 10, 2020 19:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Fuhrmann/ab1e304148f31f9361a2250c16a859d7 to your computer and use it in GitHub Desktop.
Save Fuhrmann/ab1e304148f31f9361a2250c16a859d7 to your computer and use it in GitHub Desktop.
Apache: Como configurar um VirtualHost com proxy reverso

Apache: Como configurar um VirtualHost com proxy reverso

Instala biblioteca do Apache

sudo apt-get install libapache2-mod-proxy-html

Habilita os módulos no Apache

sudo a2enmod proxy proxy_http proxy_connect proxy_html xml2enc

Reinicia o Apache

sudo service apache2 restart

Cria o arquivo com novo site

sudo nano /etc/apache2/sites-available/site-proxy.conf
<VirtualHost *:80>

    # Altere o email do administrador.
    ServerAdmin hostmaster@example.com
    ProxyRequests off
    DocumentRoot /var/www
    ProxyPreserveHost On

    # Altere a URL que vai ser usada
    # para acessar o site
    ServerName example.com

    # Caso mais de uma URL for usada,
    # adicione as outras aqui, uma em
    # cada linha.
    ServerAlias www.example.com

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

    # Alguns possíveis valores: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel error

    <Location />
        # Configure aqui a URL do site que se quer acessar.
        ProxyPass http://internal.example.com:8444/
        ProxyPassReverse http://internal.example.com:8444/
        Order allow,deny
        Allow from all
    </Location>
</VirtualHost>

Adiciona o site ao Apache

sudo a2ensite site-proxy

Reinicia (de novo) o Apache

sudo service apache2 restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment