You are not logged in.

#1 2018-06-21 23:42:09

ss
Member
Registered: 2018-06-04
Posts: 89

[SOLVED] How to serve a static website to local network

I want to make a home-made simple website accessible to devices connected to my home network. I use a simple web server called quark. I run

quark -h myhostname -p 8888 -g http -d /path/to/my-static-site

I can access the website on the same computer in a browser with http://localhost:8888

However, other devices in the same network have no access with http://myhostname:8888

Run netstat -plunt on the server

tcp        0      0 0.0.0.0:5355            0.0.0.0:*               LISTEN      267/systemd-resolve
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      279/sshd
tcp        0      0 127.0.0.1:8888          0.0.0.0:*               LISTEN      25921/quark

On other machine, run nmap -p 8888 myhostname, the port is closed. And I have absolutely no idea of what kind of service the 'sun-answerbook' could be.

8888/tcp closed sun-answerbook


My /etc/iptables/iptables.rules

*filter
:INPUT DROP [0:0]
:FORWARD DROP [0:0]
:OUTPUT ACCEPT [2:152]
:TCP - [0:0]
:UDP - [0:0]
-A INPUT -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -i eth0 -j ACCEPT
-A INPUT -m conntrack --ctstate INVALID -j DROP
-A INPUT -p icmp -m icmp --icmp-type 8 -m conntrack --ctstate NEW -j ACCEPT
-A INPUT -p udp -m conntrack --ctstate NEW -j UDP
-A INPUT -p tcp -m tcp --tcp-flags FIN,SYN,RST,ACK SYN -m conntrack --ctstate NEW -j TCP
-A INPUT -p udp -j REJECT --reject-with icmp-port-unreachable
-A INPUT -p tcp -j REJECT --reject-with tcp-reset
-A INPUT -j REJECT --reject-with icmp-proto-unreachable
-A TCP -p tcp -m tcp --dport 80 -j ACCEPT
-A TCP -p tcp -m tcp --dport 443 -j ACCEPT
-A TCP -p tcp -m tcp --dport 8888 -j ACCEPT
-A TCP -p tcp -m tcp --dport 22 -j ACCEPT
-A TCP -p tcp -m tcp --dport 53 -j ACCEPT
-A UDP -p udp -m udp --dport 53 -j ACCEPT
COMMIT

How should I made the port 8888 available to other computers?

Last edited by ss (2018-06-22 03:23:05)

Offline

#2 2018-06-21 23:57:10

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,521
Website

Re: [SOLVED] How to serve a static website to local network

ss wrote:

I can access the website on the same computer in a browser with http://localhost:8888

However, other devices in the same network have no access with http://myhostname:8888

Can you access it on the same computer via http://myhostname:8888 or from the other devices via http://XX.XX.XX.XX:8888 where the X's are the IP address?

Last edited by Trilby (2018-06-21 23:57:38)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#3 2018-06-22 00:09:39

ss
Member
Registered: 2018-06-04
Posts: 89

Re: [SOLVED] How to serve a static website to local network

Trilby wrote:

Can you access it on the same computer via http://myhostname:8888 or from the other devices via http://XX.XX.XX.XX:8888 where the X's are the IP address?

I can access with http://myhostname:8888 on the same computer.
But can't with ip address from other devices.

Offline

#4 2018-06-22 00:15:34

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,521
Website

Re: [SOLVED] How to serve a static website to local network

It looks like quark is only serving locally.  Did you build it from the aur?  I don't see any documentation for it there.  Is quark supposed to accept external connections?

EDIT: oops, I completely missed that it is bound only to the loopback - that'd definitely explain the symptoms.  Follow loqs' suggestion below.

Last edited by Trilby (2018-06-22 00:53:08)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#5 2018-06-22 00:33:33

loqs
Member
Registered: 2014-03-06
Posts: 17,317

Re: [SOLVED] How to serve a static website to local network

If you use the numeric address of the interface you want to use rather than its name does quark bind to that instead of 127.0.0.1?

Online

#6 2018-06-22 02:52:54

ss
Member
Registered: 2018-06-04
Posts: 89

Re: [SOLVED] How to serve a static website to local network

loqs wrote:

If you use the numeric address of the interface you want to use rather than its name does quark bind to that instead of 127.0.0.1?

I don't think I fully understand what you mean. At my best guess, I tried http://XXX.XXX.XXX.XX:8888 on the computer which runs the web server. Then the page is not accessiable anymore. Connection refused.

Otherwise, could you specify the steps I should carry out? Thx.

EDIT:

I see.  I should try

quark -h XXX.XXX.XX.XX -p 8888 ...

Now it works. The website is accessible for other devices in the network as well.

But what is the reason behind it? man quark says -h should follow hostname.

Last edited by ss (2018-06-22 03:02:26)

Offline

#7 2018-06-22 03:20:32

circleface
Member
Registered: 2012-05-26
Posts: 639

Re: [SOLVED] How to serve a static website to local network

Unless you have set it up in /etc/hosts or some other way, the hostname of the computer only resolves to 127.0.0.1 or localhost, which is why you can only access it from the computer it it running on.  If you bind quark to the LAN address, instead of the local hostname, it should work for every computer on the network using the IP address of the LAN adapter.

Offline

#8 2018-06-22 03:35:29

ss
Member
Registered: 2018-06-04
Posts: 89

Re: [SOLVED] How to serve a static website to local network

Thank you all for the help and explanations. Now I am really happy about this setup. Quark does exactly what I need.
Last year I wanted to serve some webpages to local devices. I tried nginx by blindly following some tutorials and config files online. Well, it did actually work. But I felt it was way more complicated than what I would ever need and understand, because at the end of the day what I wanted was just to write some blog posts or make a simple web interface ...

Offline

Board footer

Powered by FluxBB