Compare commits
2 Commits
0a9b7e65f7
...
e8a683c79d
Author | SHA1 | Date | |
---|---|---|---|
e8a683c79d
|
|||
0b509705ca
|
@@ -13,20 +13,20 @@ First, get the script and make it executable:
|
|||||||
curl -O https://git.shihaam.dev/shihaam/sarmic/raw/branch/master/nginx-allow-dynamicip/nginx-allow-dynamicip.sh
|
curl -O https://git.shihaam.dev/shihaam/sarmic/raw/branch/master/nginx-allow-dynamicip/nginx-allow-dynamicip.sh
|
||||||
chmod +x nginx-allow-dynamicip.sh
|
chmod +x nginx-allow-dynamicip.sh
|
||||||
```
|
```
|
||||||
Make sure your nginx config server block contain "#DYNAMIC" after the IP you want to change dynamically
|
Make sure your nginx config server block contain "#DYNAMIC" after the IP you want to change dynamically\
|
||||||
|
Something like the following:
|
||||||
```nginx
|
```nginx
|
||||||
#Block public access
|
#Block public access
|
||||||
allow 1.1.1.1; #DYNAMIC
|
allow 1.1.1.1; #DYNAMIC
|
||||||
deny all;
|
deny all;
|
||||||
```
|
```
|
||||||
Excute the script as root (or with sudo) with 1st arugement for config file and 2nd arugemt with domain of the IP you want to allow \
|
Excute the script as root (or with sudo) with 1st argument for config file and 2nd argument with domain of the IP you want to allow \
|
||||||
`sudo ./nginx-allow-dynamicip.sh db-sarlinode.shihaam.dev home.shihaam.me`
|
`sudo ./nginx-allow-dynamicip.sh db-sarlinode.shihaam.dev home.shihaam.me`
|
||||||
|
|
||||||
### Automate with cron
|
### Automate with cron
|
||||||
Run `crontab -e` as root as this script needs sudo.
|
Run `crontab -e` as root as this script needs to edit nginx config file and restart nginx
|
||||||
```bash
|
```bash
|
||||||
sudo crontab -e`
|
sudo crontab -e
|
||||||
```
|
```
|
||||||
I have it configured to update once every hour like this
|
I have it configured to update once every hour like this
|
||||||
```bash
|
```bash
|
||||||
@@ -34,5 +34,6 @@ I have it configured to update once every hour like this
|
|||||||
```
|
```
|
||||||
### Notes
|
### Notes
|
||||||
It is important that your nginx config files are in `/etc/nginx/sites-available/` and symlinked to `/etc/nginx/sites-enabled/`,\
|
It is important that your nginx config files are in `/etc/nginx/sites-available/` and symlinked to `/etc/nginx/sites-enabled/`,\
|
||||||
This is done by default on Debian and Ubuntu,I noticed this is not how it's configured by default on Arch Linux and CentOS, If you're using those you have bigger issues.
|
This is done by default on Debian and Ubuntu, I noticed this is not how it's configured by default on Arch Linux and CentOS, If you're using those you have bigger issues. Tested and verifed to work on Debian Linux.
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user