0

I started slowly pulling my hair out. I cannot believe such a simple thing causes me this much headache. What I'm basically trying to achieve is to make http://maris-minipc/portainer to point to http://maris-minipc:9000. That's it.

I have following setup:

  • Docker container with self-hosted Portainer and exposed on port 9000.
  • Apache web server available system-wide and used to host other things.
  • Pihole with incorporated DNS server (dnsmasq).

The URL http://maris-minipc is network-wide accessible, as I'm using it normally to access stuff hosted on previously mentioned apache web server (meaning my DNS server is working correctly). Then, I just created a new apache config file with the following content:

<VirtualHost *:80>
    ServerName maris-minipc
    ProxyPreserveHost On

    ProxyPass /portainer http://maris-minipc:9000/
    ProxyPassReverse /portainer http://maris-minipc:9000/

    ErrorLog test/error.log
    CustomLog test/access.log combined
</VirtualHost>

Whenever I access the URL http://maris-minipc/portainer I get 400: Bad Request for some reason. This at least means that the proxy is running, otherwise I would get

Not Found
The requested URL was not found on this server.

Apache/2.4.55 (Ubuntu) Server at maris-minipc Port 80

I also tried redirecting the URL to an external website and it worked.

In case you are interested into my /etc/hosts file:

127.0.0.1 localhost
127.0.1.1 Maris-MiniPC

What could be blocking the route in my local network? Is there something, specific I need to setup inside docker, because I couldn't find anything?

EDIT1: Acquired proxy debug log

[Mon Sep 11 18:44:38.419683 2023] [proxy:trace2] [pid 2059141] mod_proxy.c(884): [client 10.10.10.3:51982] AH03461: attempting to match URI path '/ha' against prefix '/ha' for proxying
[Mon Sep 11 18:44:38.419803 2023] [proxy:trace1] [pid 2059141] mod_proxy.c(1001): [client 10.10.10.3:51982] AH03464: URI path '/ha' matches proxy handler 'proxy:http://maris-minipc:8123/'
[Mon Sep 11 18:44:38.419956 2023] [proxy:trace2] [pid 2059141] proxy_util.c(2340): [client 10.10.10.3:51982] http: found worker http://maris-minipc:8123/ for http://maris-minipc:8123/
[Mon Sep 11 18:44:38.419983 2023] [proxy:debug] [pid 2059141] mod_proxy.c(1506): [client 10.10.10.3:51982] AH01143: Running scheme http handler (attempt 0)
[Mon Sep 11 18:44:38.420000 2023] [proxy:debug] [pid 2059141] proxy_util.c(2538): AH00942: http: has acquired connection for (maris-minipc:8123)
[Mon Sep 11 18:44:38.420086 2023] [proxy:debug] [pid 2059141] proxy_util.c(2596): [client 10.10.10.3:51982] AH00944: connecting http://maris-minipc:8123/ to maris-minipc:8123
[Mon Sep 11 18:44:38.420460 2023] [proxy:debug] [pid 2059141] proxy_util.c(2819): [client 10.10.10.3:51982] AH00947: connected / to maris-minipc:8123
[Mon Sep 11 18:44:38.420599 2023] [proxy:trace2] [pid 2059141] proxy_util.c(3257): http: fam 2 socket created to connect to maris-minipc:8123
[Mon Sep 11 18:44:38.420830 2023] [proxy:debug] [pid 2059141] proxy_util.c(3291): AH02824: http: connection established with 127.0.1.1:8123 (maris-minipc:8123)
[Mon Sep 11 18:44:38.420909 2023] [proxy:debug] [pid 2059141] proxy_util.c(3480): AH00962: http: connection complete to 127.0.1.1:8123 (maris-minipc)
[Mon Sep 11 18:44:38.426673 2023] [proxy:debug] [pid 2059141] proxy_util.c(2554): AH00943: http: has released connection for (maris-minipc:8123)
2
  • 1
    Are you sure you're getting the 400 error from your proxy and not from Portainer itself? Some backend services may need extra configuration for being proxied. Commented Sep 11, 2023 at 17:06
  • Very possible, I left it open as an option. Unfortunately, I don't have enough experience to know that. I guess I tried everything that had to do with the apache web server, meaning it points into that direction. I guess I'll have to tweak my container settings and try out.
    – Jumpman
    Commented Sep 11, 2023 at 17:22

1 Answer 1

0

So guys, I managed to solve it. Thank you @u1686_gravity for the assistance!

Certain containers require explicit rules to be able to communicate with proxy servers (configured in the container config). On top of that, most of them use Websockets and therefore require additional proxy server directives to support this.

There is one minor feature/bug in Pihole that denied me usage of subdomains. Pihole uses dnsmasq beneath the hood. Creating an A record (test.home) in Pihole, means it won't support subdomain wildcards (*.test.home). The solution was to add it manually to dnsmasq.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .