Điểm:0

Fritz!Box & Ubuntu: Expose URL in LAN with Apache Httpd and Bind

lá cờ ck

I hope someone can help me with this - I thought - simple task.

Situation:

On my private LAN I run an Internet-Router ("Fritz!Box") and a Raspberry Pi with Ubuntu 20.04 LTS on it. I developed a little Spring Boot Web-App for private purposes that I only want to use in my LAN (or maybe reach via VPN from the outside). The native URL of the Web-App is "http://ubuntu:8080", because my Raspberry is called "ubuntu" and the app runs on a Tomcat-Server. Now I want to expose an URL like e.g. "http://thats-my.app" inside the LAN and use it as base URL for the app. For the moment, curl on the ubuntu can reach it, my other PC can't.

Even better would be a FQDN "http://wow.thats-my.app" (with a subdomain) so I can use the same domain and top-level-domain for all apps, and only vary the subdomain, like "http://super.thats-my.app" and so on.. Disclaimer: Since I work via SSH all configuration is done Terminal-only. Please consider that I don't use the Desktop Surface of Ubuntu.

Thank you in advance for your time and hopefully for your help!

Here are the setups I did to the ubuntu system. What is not shown here is commented out!:

ufw

Status: active

     To                         Action      From
     --                         ------      ----
[ 1] 9090/tcp                   ALLOW IN    Anywhere                   # UBUNTU-COCKPIT
[ 2] 3306/tcp                   ALLOW IN    Anywhere                   # MYSQL
[ 3] Apache Full                ALLOW IN    Anywhere                   # :80,:443
[ 4] Bind9                      ALLOW IN    Anywhere                   # :53
[ 5] OpenSSH                    ALLOW IN    Anywhere                   # :22
[ 6] 8080:8090/tcp              ALLOW IN    Anywhere                   # TOMCAT
[ 7] 9090/tcp (v6)              ALLOW IN    Anywhere (v6)              # UBUNTU-COCKPIT
[ 8] 3306/tcp (v6)              ALLOW IN    Anywhere (v6)              # MYSQL
[ 9] Apache Full (v6)           ALLOW IN    Anywhere (v6)              # :80,:443
[10] Bind9 (v6)                 ALLOW IN    Anywhere (v6)              # :53
[11] OpenSSH (v6)               ALLOW IN    Anywhere (v6)              # :22
[12] 8080:8090/tcp (v6)         ALLOW IN    Anywhere (v6)              # TOMCAT

/etc/hosts

127.0.0.1 localhost.localdomain localhost
127.0.1.1 ubuntu
127.0.1.1 thats-my.app

(--> no entries for IPv6)

/etc/apache2/sites-available/thats-my.conf

<VirtualHost *:80>
        ServerName thats-my.app
        ServerAlias thats-my
        ProxyRequests Off
        <Proxy *>
                Order deny,allow
                Allow from all
        </Proxy>
        ProxyPreserveHost On
        ProxyPass               / http://localhost:8080/
        ProxyPassReverse        / http://localhost:8080/
</VirtualHost>

--> Symbolic link to sites-enabled directory

/etc/bind/named.conf.local

zone "thats-my.app" IN {
        type master;
        file "/etc/bind/forward.thats-my.app.db";
        allow-update { none; };
};

zone "178.168.192.in-addr.arpa" IN {
        type master;
        file "/etc/bind/reverse.thats-my.app.db";
        allow-update { none; };
};

/etc/bind/named.conf.options

options {
        directory "/var/cache/bind";
        forwarders {
        1.1.1.1;
        1.0.0.1;
        8.8.8.8;
        8.8.4.4;
        };
        dnssec-validation auto;
        listen-on-v6 { any; };
        allow-query { any; };
};

/etc/bind/forward.thats-my.app.db

$TTL    604800
@       IN      SOA     ns1.thats-my.app. admin.ns1.thats-my.app. (
                              5         ; Serial
                         604800         ; Refresh
                          86400         ; Retry
                        2419200         ; Expire
                         604800 )       ; Negative Cache TTL
;
@       IN      NS      ns1.thats-my.app.
ns1     IN      A       192.168.178.23

/etc/bind/reverse.thats-my.app.db

$TTL    604800
@       IN      SOA     thats-my.app. admin.thats-my.app. (
                              4         ; Serial
                         604800         ; Refresh
                          86400         ; Retry
                        2419200         ; Expire
                         604800 )       ; Negative Cache TTL
;
@       IN      NS      ns1.thats-my.app.
ns1     IN      A       192.168.178.23
23      IN      PTR     ns1.thats-my.app.

--> input to Terminal:

sudo systemctl restart named
sudo systemctl restart apache2
sudo systemctl restart bind9

--> DNS Configuration in the Router

Set DNS IPv4 IP to 192.168.178.23 (primary and secondary)

Set DNS IPv6 IP to IPv6 address of the ubuntu machine (primary and secondary)

Here's what I got:

On the local Ubuntu-Server

$ curl thats-my.app -> OK
$ dig thats-my.app -> status: NOERROR   *but*  SERVER 1.1.1.1#53 ???
$ dig thats-my.app @127.0.1.1 -> "connection timed out!"
$ dig thats-my.app @192.198.178.23 -> "connections timed out!"

On the LAN Windows-PC PowerShell

curl thats-my.app -> cannot be resolved

On the LAN Windows-PC Chrome Browser

http://thats-my.app -> Website unreachable / DNS_PROBE_FINISHED_NXDOMAIN

If you look at the "dig" - results it seams to me that Bind9 doesn't work right here. What do you think?

Thanks!

Điểm:0
lá cờ ck

Cuối cùng tôi đã tìm ra giải pháp: Bộ định tuyến ("AVM Fritz!Box", rất phổ biến ở Đức) có tính năng bảo mật "DNS-Rebind-Protection" ngăn các yêu cầu DNS từ trong mạng LAN đến máy chủ khác trong mạng LAN. Khi bạn thiết lập một ngoại lệ bằng cách nhập, ví dụ:TLD "lan" hoặc trong trường hợp ở trên là "ứng dụng" trong hộp văn bản, máy chủ DNS cục bộ của bạn hoạt động hoàn toàn bình thường. Bạn có thể loại bỏ các giao nhận.

Tái bút: Bạn không cần mục trong /etc/hosts !

PPS: https://bind9.readthedocs.io/en/latest/index.html

Chúc may mắn!

Đăng câu trả lời

Hầu hết mọi người không hiểu rằng việc đặt nhiều câu hỏi sẽ mở ra cơ hội học hỏi và cải thiện mối quan hệ giữa các cá nhân. Ví dụ, trong các nghiên cứu của Alison, mặc dù mọi người có thể nhớ chính xác có bao nhiêu câu hỏi đã được đặt ra trong các cuộc trò chuyện của họ, nhưng họ không trực giác nhận ra mối liên hệ giữa câu hỏi và sự yêu thích. Qua bốn nghiên cứu, trong đó những người tham gia tự tham gia vào các cuộc trò chuyện hoặc đọc bản ghi lại các cuộc trò chuyện của người khác, mọi người có xu hướng không nhận ra rằng việc đặt câu hỏi sẽ ảnh hưởng—hoặc đã ảnh hưởng—mức độ thân thiện giữa những người đối thoại.