From 4c038de8b3d04f21f3936c46cbf878c2b634ae32 Mon Sep 17 00:00:00 2001 From: Chris Caron Date: Tue, 18 Feb 2025 14:59:58 -0500 Subject: [PATCH] IPV4_ONLY and IPV6_ONLY environment control added (#235) --- README.md | 2 ++ apprise_api/etc/nginx.conf | 4 ++-- apprise_api/gunicorn.conf.py | 6 ++---- apprise_api/supervisord-startup | 16 ++++++++++++++++ 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 0819af5..a584159 100644 --- a/README.md +++ b/README.md @@ -398,6 +398,8 @@ The use of environment variables allow you to provide over-rides to default sett |--------------------- | ----------- | | `PUID` | The User ID you wish the Apprise instance under the hood to run as. The default is `1000` if not otherwise specified. | `PGID` | The Group ID you wish the Apprise instance under the hood to run as. The default is `1000` if not otherwise specified. +| `IPV4_ONLY` | Force an all IPv4 only environment (default supports both IPV4 and IPv6). Nothing is done if `IPV6_ONLY` is also set as this creates an ambigious setup. +| `IPV6_ONLY` | Force an all IPv6 only environment (default supports both IPv4 and IPv6). Nothing is done if `IPV4_ONLY` is also set as this creates an ambigious setup. | `APPRISE_DEFAULT_THEME` | Can be set to `light` or `dark`; it defaults to `light` if not otherwise provided. The theme can be toggled from within the website as well. | `APPRISE_DEFAULT_CONFIG_ID` | Defaults to `apprise`. This is the presumed configuration ID you always default to when accessing the configuration manager via the website. | `APPRISE_CONFIG_DIR` | Defines an (optional) persistent store location of all configuration files saved. By default:
- Configuration is written to the `apprise_api/var/config` directory when just using the _Django_ `manage runserver` script. However for the path for the container is `/config`. diff --git a/apprise_api/etc/nginx.conf b/apprise_api/etc/nginx.conf index 5bef79a..66d3386 100644 --- a/apprise_api/etc/nginx.conf +++ b/apprise_api/etc/nginx.conf @@ -42,8 +42,8 @@ http { client_body_in_file_only off; server { - listen 8000; - listen [::]:8000; + listen 8000; # IPv4 Support + listen [::]:8000; # IPv6 Support # Allow users to map to this file and provide their own custom # overrides such as diff --git a/apprise_api/gunicorn.conf.py b/apprise_api/gunicorn.conf.py index 065b192..422d3b3 100644 --- a/apprise_api/gunicorn.conf.py +++ b/apprise_api/gunicorn.conf.py @@ -38,10 +38,8 @@ pythonpath = '/opt/apprise/webapp' # bind to port 8000 bind = [ - # ipv4 - '0.0.0.0:8000', - # ipv6 - '[::]:8000' + '0.0.0.0:8000', # IPv4 Support + '[::]:8000', # IPv6 Support ] # Workers are relative to the number of CPU's provided by hosting server diff --git a/apprise_api/supervisord-startup b/apprise_api/supervisord-startup index 83220c4..6efa90d 100755 --- a/apprise_api/supervisord-startup +++ b/apprise_api/supervisord-startup @@ -70,6 +70,22 @@ sed -i -e "s/^\(user[ \t]*=[ \t]*\).*$/\1$USER/g" \ sed -i -e "s/^\(group[ \t]*=[ \t]*\).*$/\1$GROUP/g" \ /opt/apprise/webapp/etc/supervisord.conf +if [ "${IPV4_ONLY+x}" ] && [ "${IPV6_ONLY+x}" ]; then + echo -n "Warning: both IPV4_ONLY and IPV6_ONLY flags set; ambigious; no changes made." + +# Handle IPV4_ONLY flag +elif [ "${IPV4_ONLY+x}" ]; then + echo -n "Enforcing Exclusive IPv4 environment... " + sed -ibak -e '/IPv6 Support/d' /opt/apprise/webapp/etc/nginx.conf /opt/apprise/webapp/gunicorn.conf.py && \ + echo "Done." || echo "Failed!" + +# Handle IPV6_ONLY flag +elif [ "${IPV6_ONLY+x}" ]; then + echo -n "Enforcing Exclusive IPv6 environment... " + sed -ibak -e '/IPv4 Support/d' /opt/apprise/webapp/etc/nginx.conf /opt/apprise/webapp/gunicorn.conf.py && \ + echo "Done." || echo "Failed!" +fi + # Working directory cd /opt/apprise