HOME DOCUMENTATION DOWNLOADS BLOG

Reverse Proxy for HTML5 Server

This article describes configuration of Apache server to be used as a reverse proxy for HTML5 server.

Modify HTML5’s appsettings.json

Set BehindProxy as true.

Configure Apache Server

Example:

<IfModule mod_ssl.c>
  <VirtualHost *:443>
    RequestHeader set "X-Forwarded-Proto" expr=%{REQUEST_SCHEME}
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html
    ProxyPreserveHost On	
    ProxyPass / http://127.0.0.1:8080/ retry=0
    ProxyPassReverse / http://127.0.0.1:8080/
    ErrorLog ${APACHE_LOG_DIR}/sslerror.log
    CustomLog ${APACHE_LOG_DIR}/sslaccess.log combined
    SSLEngine on
    SSLProtocol all -SSLv2
    SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:!RC4+RSA:+HIGH:+MEDIUM:!LOW:!RC4
    SSLCertificateFile	/etc/ssl/certs/ssl-cert-snakeoil.pem
    SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key
  </VirtualHost>
</IfModule>

Configure Nginx Server

Example:

server {	  
        listen 443 ssl;
        listen [::]:443 ssl;

        include snippets/self-signed.conf;
        include snippets/ssl-params.conf;

        access_log /var/log/nginx/reverse-access.log;
        error_log /var/log/nginx/reverse-error.log;

        location / {
		proxy_hide_header X-Frame-Options;
		proxy_set_header Host $host;
	    proxy_set_header X-Real-IP $remote_addr;
	    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
		proxy_set_header X-Forwarded-Proto $scheme;
		proxy_pass http://127.0.0.1:8080;
  }
}