Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change default web port #85

Closed
buurman opened this issue Jan 8, 2017 · 35 comments
Closed

Change default web port #85

buurman opened this issue Jan 8, 2017 · 35 comments

Comments

@buurman
Copy link

buurman commented Jan 8, 2017

Could you change the default port to something else? Port 80 is a pain on my server, at the moment I just mount a custom lighttpd.conf (changed 80 to 8088) to /etc/lighttpd/lighttpd.conf and it works like a charm.

The reverse proxy solution isn't always easy and this is a quick solution, you could just load an editted conf file with the dockerfile.

@diginc
Copy link
Collaborator

diginc commented Jan 8, 2017

have you tried changing the port with docker's NAT? e.g. docker run -p 8088:80 ?

I was under the impression this style of ad blocking required pi-hole be the default server in charge of port 80, this way when hitting a random ad domain over http (port 80) it gets the empty ad blocked page.

@buurman
Copy link
Author

buurman commented Jan 8, 2017

I did, but that's only useful when using a bridged network connection, and when doing it like so it doesn't pickup de client ip's and it sees all the requests as coming from the docker container IP. Setting the serverip doesn't help.

Maybe it's because i'm running it on a Synology NAS? Either way, mounting a different conf is working great. Didn't encounter any issues so far.

@diginc
Copy link
Collaborator

diginc commented Jan 8, 2017

so you're running --net host or another non bridged (NAT) style? Could you post your entire docker run command so I could play around with running in that style?

I assume synology also runs it's web interface on port 80 so you're getting around that.

@buurman
Copy link
Author

buurman commented Jan 8, 2017

I don't know the command, it's nice gui from Synology itself, but yes it's --net. The only reason I get around port 80 is that I adjusted the port in the lighttpd.conf file of the docker container to 8088.

@diginc
Copy link
Collaborator

diginc commented Jan 8, 2017

I'll see about adding the customization of port option after #84 is finished.

@buurman
Copy link
Author

buurman commented Jan 8, 2017

Nice, thanks for the effort!

@diginc
Copy link
Collaborator

diginc commented Jan 18, 2017

Related: #88.

I think the recommendation I made in #88 to make pi-hole your top most apache VHOST should work for you too.

@buurman
Copy link
Author

buurman commented Jan 18, 2017

I tried it before and it wasn't helping.. I rather not want to manually chance configs on the NAS.

@tonyklawrence
Copy link

I've been looking into this as I also run pi-hole in docker on my DS916+. I've posted an article on how I solved the issue. I know you don't want to manually change configs, but unless Synology add support for this there is no other option available.

http://tonylawrence.com/post/unix/synology/freeing-port-80/

@buurman
Copy link
Author

buurman commented Feb 9, 2017

When using your NAS also as a webserver this is not a great solution so I will stick to my current solution/workaround which is loading/mounting a custom lighttpd.conf file. This is still working flawless as far as I can judge.

@tonyklawrence
Copy link

Buurman, would you mind explaining your full solution? I'm not sure how you can get pi-hole to dns your docker container if it's not running on port 80?

@buurman
Copy link
Author

buurman commented Feb 20, 2017

I can give it a try this evening. Could you explain to me what shouldn't be working according to you?

@tonyklawrence
Copy link

tonyklawrence commented Feb 20, 2017

When pi-hole decides it needs to block an advert, the DNS server will return your configured server ip - in this case the IP address of the Synology. This means that when the webpage attempts to download the advert instead of asking the ad-server it asks the Synology which should return a blank page.

However, because DSM is listening on port 80, instead of returning a black page it returns the Synology 404 page as the requested advert does not exist. This is especially problematic if you have Synology redirect HTTP to HTTPS as this then creates certificate warnings.

I've not tried running a web server on the Synology so I don't know what this involves but it might mean that instead of attempting to load the advert from the DSM it is instead requesting from your own website that is running on port 80 and returning your websites 404 page?

@buurman
Copy link
Author

buurman commented Feb 20, 2017

Aha I understand.. my 'solution' is a solution for the Admin page and not for the 'block page'.

I performed a small test by trying to go to 'googleadservices.com' and instead I ended at my NAS root webpage.. which for my use is fine because it's a blank page that says 'Nope..' :-) None of my websites are in the rootfolder so the result is simular as the pi-hole block page.

@tonyklawrence
Copy link

tonyklawrence commented Feb 20, 2017

So an alternative could be to run your own website on the Synology with a blank root page? Is this something that is easy through the UI?

edit: looks like you can't run a website on port 80 unless you give it a name which kinda defeats the purpose.

@buurman
Copy link
Author

buurman commented Feb 20, 2017

I guess most people playing with Synology/Docker/Pi-Hole should be able to do this. But it depends on how they manage their websites.

But essentialy it can be done in three steps:
Step 1) Install 'Webstation' if not already installed
Step 2) Create file index.html in the /volume#/web folder.
Step 3) Open index.html with a texteditor en paste something like:

<HTML>
<HEAD><title>Website Blocked</title></HEAD>
<BODY>Nope.. blocked!</BODY>
</HTML>

Done..

@tonyklawrence
Copy link

Yes, that's what I'm playing with atm. Only just installed webstation.
I'm guessing the default is to look in /web and if you update that like you said then you don't need to add any virtual hosts. I'm going to have a play.

Last thing, instead of modifying the lighttpd.conf to allow access to admin, would it not be possible to add a name based reverse proxy that would forward all traffic to pihole.myhost.com -> pi-hole.docker ??

@buurman
Copy link
Author

buurman commented Feb 20, 2017

It would be possible, DSM6 can do this (Application Portal / Reverse proxy).
But you have to make sure pihole.myhost.com gets rewritten to /admin inside the docker container. It's kinda vulnerable that way because there's no user/pass or something needed to access the admin page.

@tonyklawrence
Copy link

Thanks for your help, I think setting up a blank root website is a good alternative to modifying the templates (who knows what this might break in future releases).

I've decided to reverse proxy my pihole docker and just bookmark the host with /admin, this seems to work ok.

@dschaper
Copy link
Member

We really don't try to break existing installations too often, it just looks a lot like that. :)

@tonyklawrence
Copy link

I was talking more about breaking future Synology DSM releases (it's those templates i edited) rather than pi-hole itself.

@dschaper
Copy link
Member

Eventually one of us Pi-hole developers will have to break down and pick up a Synology device so we can be of more assistance and help diginc out a little more with Docker on Synology.

@buurman
Copy link
Author

buurman commented Feb 20, 2017

If you or diginc need volunteers for testing.. count me in.

@tonyklawrence
Copy link

An alternative to buying a Synology is running Xpenology (can run inside VMWare I believe).
I've no experience with this but could be an option initially?

@dschaper
Copy link
Member

Thanks, I'll take a look at that.

@buurman
Copy link
Author

buurman commented Feb 20, 2017

I've got a Synology DS412+ as well as a Xpenology server (on a HP Gen8 Microserver).. both work great but be aware that a Xpenology server depends on community updates.

@MattPark
Copy link

MattPark commented Mar 4, 2017

@buurman Did you get the DHCP part working in Synology Docker, btw?

@diginc diginc added the synology label Mar 4, 2017
@buurman
Copy link
Author

buurman commented Mar 4, 2017

Nope, don't need it so I didn't test it

@diginc
Copy link
Collaborator

diginc commented Nov 15, 2017

Checkout the latest alpine_dev and debian_dev tags for this new features. I'll merge to the production tags ASAP.

@tonyklawrence
Copy link

tonyklawrence commented Nov 28, 2017

I can confirm that the alpine_dev tag works for me on my synology running using host networking. I can change the http port so there is no clash.
The other thing I needed to do was to specify DNSMASQ_LISTENING=all as en0 does not exist in this case.

Oh and thanks!

A small post on how I did this is here:
http://tonylawrence.com/post/unix/synology/running-pihole-inside-docker/

@tERB00
Copy link

tERB00 commented Jan 24, 2018

Docker WEB_PORT variable does not work for some reason... It still listens for 80 port. Anybody know why?

@Tatsh
Copy link

Tatsh commented Feb 9, 2018

I changed this in the Debian image by modifying the lighttpd.conf file and forcing it to be readonly in the volume mount:

docker ... -v ~/dev/pihole/lighttpd.conf:/etc/lighttpd/lighttpd.conf:ro ...`

The file has this line:

server.port              = 37337

Then in nginx locally running on this machine I have this configuration file loaded:

upstream pihole {
    server 192.168.1.254:37337;
}

server {
    listen 80;
    server_name "~^.*$";
    access_log off;

    location / {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_pass http://pihole;
    }
}

Yes, it works. I would like to not have to override lighttpd.conf.

@keithah
Copy link

keithah commented Feb 13, 2018

I was following @tonyklawrence's instructions for setting up on synology and can confirm WEB_PORT is no longer respected as well. 'latest' nor 'debian_dev' works, I did have it working with 'debian' however.

declare -x TAG="debian_dev"
declare -x TERM="xterm"
declare -x WEB_PORT="8000"

Still gets 'port 80 in use' errrors.

@github-actions
Copy link

This issue is stale because it has been open 30 days with no activity. Please comment or update this issue or it will be closed in 5 days.

@PromoFaux
Copy link
Member

the WEB_PORT variable appears to be working fine in the latest image. Feel free to reopen if this is still an issue for you

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants