首页 > 解决方案 > Apache reverse proxy subdomain to port

问题描述

I'm trying to setup an apache reverse-proxy to achive following results.

Expected Results

When visiting https://service.example.com, apache will serve content from http://localhost:8080, which is another service/webserver being run on the localhost.

Actual Results

When visiting https://service.example.com apache gives back content from https://example.com (and gives some certificate issues).

Current configuartion

There is an SSL apache server being run at https://example.com with a lets encrypt wildcard certificate.

The virtual-host file that is supposed to enable the reverse-proxy looks the following

<VirtualHost *:80>
        ServerName service.example.com

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

        ProxyRequests Off
        <Proxy *>
          Order deny,allow
          Allow from all
        </Proxy>

        ProxyPass / http://localhost:8080
        ProxyPassReverse / http://localhost:8080

        <Location />
          Order allow,deny
          Allow from all
        </Location>

   </VirtualHost>

The file has been activated with a2ensite service.conf and has symbolic link to /sites-enabled

How does one resolve this problem? All help is appreciated.

标签: apacheubuntunetworkingreverse-proxy

解决方案


如果问题仍然相关,则您在域末尾缺少斜杠:

    ProxyPass / http://localhost:8080/
    ProxyPassReverse / http://localhost:8080/

另外,不要忘记启用代理模块:a2enmod proxy_http


推荐阅读