1

I'm using a raspberry pi with apache2 to manage my websites. I have multiple docker images running on different ports. I want to redirect (without url changes) scanner.raspberry.local to localhost:1234. To do so, I've followed these two posts :

In the end, I only have one virtualhost working (the first one). Here is my config :

# Home page : working properly
<VirtualHost *:80>
        ServerName          raspberry.local
    ProxyPreserveHost   On
    ProxyRequests       Off

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

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

</VirtualHost>

Scanner : not working : "could not resolve host" when I cURL

<VirtualHost *:80> ServerName scan.raspberry.local

    ProxyPreserveHost   On
    ProxyRequests       Off

    ProxyPass           / http://localhost:1234/
    ProxyPassReverse    / http://localhost:1234/

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

</VirtualHost>

I tried installing nginx, but I end up with the same thing, the first virtualhost works, but the second one (the subdomain), couldn't be resolved via cURL, even directly on the server. I've followed this post to help me. I ended with this :

server {
    listen 80;
    server_name raspberry.local;
location / {
    proxy_pass http://localhost:8080;
}   

}

server { listen 80; server_name scan.raspberry.local;

location / {
    proxy_pass http://localhost:1234;
}   

}

I have no errors on any log files, when I use apache2ctl -S it finds my virtualhosts with no problems, same when I do apache2ctl configtest. I have enabled the proxy, proxy_http and rewrite modules. And my config is properly enabled in /etc/apache2/sites-enabled/000-default.conf (symlink from sites-available).

My system:

  • Raspberry Pi 4 8Gb on Ubuntu 22.04

Also, I'm using a VPN hosted on my Pi, And i've added the proper config to my /etc/host and c:\Windows\System32\Drivers\etc\hosts (WSL/Windows).

I know there is a ton of posts about apache2's config. But I can't find any with the same problem.

tholeb
  • 59

2 Answers2

0

Scanner : not working : "could not resolve host" when I cURL

This means that curl cannot resolve the IP address for the domain name. It means that the DNS entry for the destination domain is not configured.

The DNS configuration is not related to Apache2 nor nginx configuration.

Tero Kilkanen
  • 38,887
0

To resolve this, I installed dnsmasq, configured it, and added the DNS server to /etc/resolve.conf.

Now, I can cURL to x.subdomain.local if I add on each machine my DNS server.

tholeb
  • 59