Make forwarded_port file location configurable (#43)
* Make port forwarding status file dynamic * Readme updates
This commit is contained in:
@@ -31,6 +31,7 @@ ENV USER= \
|
|||||||
UNBLOCK= \
|
UNBLOCK= \
|
||||||
EXTRA_SUBNETS= \
|
EXTRA_SUBNETS= \
|
||||||
PORT_FORWARDING=false \
|
PORT_FORWARDING=false \
|
||||||
|
PORT_FORWARDING_STATUS_FILE="/forwarded_port" \
|
||||||
PROXY=on \
|
PROXY=on \
|
||||||
PROXY_LOG_LEVEL=Critical \
|
PROXY_LOG_LEVEL=Critical \
|
||||||
PROXY_PORT=8888 \
|
PROXY_PORT=8888 \
|
||||||
|
|||||||
@@ -157,6 +157,7 @@ docker run --rm --network=container:pia alpine:3.10 wget -qO- https://ipinfo.io
|
|||||||
| `UNBLOCK` | | comma separated string (i.e. `web.com,web2.ca`) to unblock hostnames |
|
| `UNBLOCK` | | comma separated string (i.e. `web.com,web2.ca`) to unblock hostnames |
|
||||||
| `EXTRA_SUBNETS` | | comma separated subnets allowed in the container firewall (i.e. `192.168.1.0/24,192.168.10.121,10.0.0.5/28`) |
|
| `EXTRA_SUBNETS` | | comma separated subnets allowed in the container firewall (i.e. `192.168.1.0/24,192.168.10.121,10.0.0.5/28`) |
|
||||||
| `PORT_FORWARDING` | false | Set to `true` to read the forwarded port |
|
| `PORT_FORWARDING` | false | Set to `true` to read the forwarded port |
|
||||||
|
| `PORT_FORWARDING_STATUS_FILE` | /forwarded_port | Set to the file where you want to write the forwarded port |
|
||||||
| `PROXY` | `on` | `on` or `off`, to switch the internal HTTP proxy |
|
| `PROXY` | `on` | `on` or `off`, to switch the internal HTTP proxy |
|
||||||
| `PROXY_LOG_LEVEL` | `Critical` | `Info`, `Warning`, `Error` or `Critical` |
|
| `PROXY_LOG_LEVEL` | `Critical` | `Info`, `Warning`, `Error` or `Critical` |
|
||||||
| `PROXY_PORT` | `8888` | `1024` to `65535` internal port for HTTP proxy |
|
| `PROXY_PORT` | `8888` | `1024` to `65535` internal port for HTTP proxy |
|
||||||
@@ -240,7 +241,7 @@ There are various ways to achieve this, depending on your use case.
|
|||||||
|
|
||||||
## Port forwarding
|
## Port forwarding
|
||||||
|
|
||||||
By setting `PORT_FORWARDING` environment variable to `true`, the forwarded port will be read and written to `/forwarded_port`.
|
By setting `PORT_FORWARDING` environment variable to `true`, the forwarded port will be read and written to the file specified in `PORT_FORWARDING_STATUS_FILE` (by default, this is set to `/forwarded_port`). If the location for this file does not exist, it will be created automatically.
|
||||||
|
|
||||||
You can mount this file as a volume to read it from other containers.
|
You can mount this file as a volume to read it from other containers.
|
||||||
|
|
||||||
|
|||||||
@@ -20,9 +20,12 @@ if [ "$json" == "" ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
port=`echo $json | jq .port`
|
port=`echo $json | jq .port`
|
||||||
port_file="/forwarded_port"
|
port_status_folder=`dirname "${PORT_FORWARDING_STATUS_FILE}"`
|
||||||
echo "$port" > $port_file
|
if [ ! -d "${port_status_folder}" ];
|
||||||
printf " * Written forwarded port to $port_file\n"
|
mkdir -p "${port_status_folder}"
|
||||||
|
fi
|
||||||
|
echo "$port" > "${PORT_FORWARDING_STATUS_FILE}"
|
||||||
|
printf " * Written forwarded port to ${PORT_FORWARDING_STATUS_FILE}\n"
|
||||||
ip=`wget -qO- https://diagnostic.opendns.com/myip`
|
ip=`wget -qO- https://diagnostic.opendns.com/myip`
|
||||||
exitOnError $? "Unable to read remote VPN IP"
|
exitOnError $? "Unable to read remote VPN IP"
|
||||||
printf " * Forwarded port is $port on remote VPN IP $ip\n"
|
printf " * Forwarded port is $port on remote VPN IP $ip\n"
|
||||||
|
|||||||
Reference in New Issue
Block a user