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

How can I expose apprise on another port? #210

Open
amigthea opened this issue Oct 9, 2024 · 4 comments
Open

How can I expose apprise on another port? #210

amigthea opened this issue Oct 9, 2024 · 4 comments
Labels
question Further information is requested

Comments

@amigthea
Copy link

amigthea commented Oct 9, 2024

I use a custom docker macvlan network and I'm trying to find where I can change the default port 8000 to 80, any help? thank you, amazing project

@amigthea amigthea added the question Further information is requested label Oct 9, 2024
@caronc
Copy link
Owner

caronc commented Dec 20, 2024

I'm not sure about docker macvlan, but just re-map the port you want when you call your docker:

# The below maps the internal 8000 to your external port 8000
docker run --name apprise \
   -p 8000:8000 \
   -e PUID=$(id -u) \
   -e PGID=$(id -g) \
   -e APPRISE_STATEFUL_MODE=simple \
   -e APPRISE_WORKER_COUNT=1 \
   -v /etc/apprise:/config \
   -d apprise/local:latest

# What you're asking for is just a slight tweak to the same call:
   -p 80:8000 \
   -e PUID=$(id -u) \
   -e PGID=$(id -g) \
   -e APPRISE_STATEFUL_MODE=simple \
   -e APPRISE_WORKER_COUNT=1 \
   -v /etc/apprise:/config \
   -d apprise/local:latest

See here

@amigthea
Copy link
Author

thank you for joining @caronc, port mapping is not available with macvlan driver

@caronc
Copy link
Owner

caronc commented Feb 18, 2025

I would suggest switching to something that will map it for you then. Alternatively you can leverage iptables. Here is how to do it (taken from ChatGPT):

You can use the nat table’s PREROUTING chain to redirect incoming TCP traffic from port 8000 to port 8080. For example, run:

sudo iptables -t nat -A PREROUTING -p tcp --dport 8000 -j REDIRECT --to-port 8080

Explanation

  • -t nat: Specifies the NAT table.
  • -A PREROUTING: Appends the rule to the PREROUTING chain (which is used for altering packets as soon as they come in).
  • -p tcp: Applies the rule to TCP packets.
  • --dport 8000: Matches packets destined for port 8000.
  • -j REDIRECT: Jumps to the REDIRECT target, which alters the destination port.
  • --to-port 8080: Redirects the traffic to port 8080.

Note

  • If you’re redirecting traffic generated on the local machine (i.e., originating from the same host), you might need to use the OUTPUT chain:

    sudo iptables -t nat -A OUTPUT -p tcp --dport 8000 -j REDIRECT --to-port 8080
  • Remember that iptables rules are not persistent across reboots by default. To save them, you might need to use tools like iptables-save or configure your distribution’s firewall persistence service.

@amigthea
Copy link
Author

unfortunately the iptables rules in the host net namespace are irrelevant when using the macvlan driver, because the packet never passes through the host net namespace. Thus the option to change the default port would come very handy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants