Reverse proxy using Apache2

  • 109 Views
  • Last Post 02 September 2019
schuwima posted this 23 August 2019

OS Name/Version: Ubuntu 18.04 LTS

Product Name/Version: AMP TITAN v1.8.3.4, built 09/08/2019 13:00

Problem Description:

The Server itself is publicly only available throught IPv6. I am using NAT to publish a small range of ports for gameserver. Internal the Server is using an IPv4 address.

I am trying to use Apache2 as a reverse proxy (currently HTTP only for testing purpose - NGINX is not an option), however I only see the website as pure HTML without any style information. Interaction with the website is not possible.

Is it possible to use Apache2 as a reverse proxy for AMP?

Steps to reproduce:

Apache configuration (removed domain names, changed internal address):

<virtualhost *:80="">
    ProxyPreserveHost on

    ServerAdmin webmaster@domain.tld
    ServerName game.domain.tld

    ProxyPass / http://10.20.30.40:8080
    ProxyPassReverse / http://10.20.30.40:8080

Actions taken to resolve so far: Tried to "convert" the header variables from the NGINX reverse proxy part of the documentation.

Order By: Standard | Newest | Votes
Mike posted this 27 August 2019

It's definitely possible (although a pain to get right in places because of websockets) - what browser errors are you getting?

Das_Pflanze posted this 02 September 2019

Just FYI: I'm using Plesk with a docker setup. To access the web interface on a subdomain I need to proxy all connections to the belonging local docker port (8099 in my case).

Due the fact that Plesk is using Apache and NGINX in combination I need to first proxy all requests to Apache2 and then pass them to the docker container. So my configuration in Plesk looks like this:

NGINX (as you don't use NGINX, I think you can just ignore it):

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        Upgrade $http_upgrade;
proxy_set_header        Connection "Upgrade";
proxy_http_version      1.1;
proxy_redirect          off;
proxy_buffering         off;

location /stream/ {
    proxy_pass http://127.0.0.1:8099;
    proxy_http_version 1.1;
    proxy_buffering off;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "Upgrade";
    proxy_read_timeout 86400;
}

Apache2:

# HSTS (mod_headers is required) (15768000 seconds = 6 months)
Header always set Strict-Transport-Security "max-age=15768000"

# Encoded slashes need to be allowed
AllowEncodedSlashes     NoDecode

# Container uses a unique non-signed certificate
SSLProxyEngine On
SSLProxyVerify None
SSLProxyCheckPeerCN Off
SSLProxyCheckPeerName Off
SSLProxyCheckPeerExpire off

ProxyPass "/stream/" "ws://127.0.0.1:8099/stream/"
ProxyPassReverse "/stream/" "wss://127.0.0.1:8099/stream/"
ProxyPass "/" "http://127.0.0.1:8099/"
ProxyPassReverse "/" "https://127.0.0.1:8099/"
ProxyPreserveHost On

Maybe that's what you're looking for

Mike posted this 02 September 2019

I'm after the errors shown in the browsers F12 console.

Close