Compare commits
	
		
			2 Commits
		
	
	
		
			874f32a33f
			...
			13a9d0af4a
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						
						
							
						
						13a9d0af4a
	
				 | 
					
					
						|||
| 
						
						
							
						
						535a4f8d54
	
				 | 
					
					
						
@@ -1,6 +1,6 @@
 | 
			
		||||
#!/bin/bash
 | 
			
		||||
 | 
			
		||||
CONFIG=/etc/nginx/sites-enabled/$1
 | 
			
		||||
CONFIG=/etc/nginx/sites-available/$1
 | 
			
		||||
DOMAIN=$2
 | 
			
		||||
 | 
			
		||||
IP=$(dig $DOMAIN +short)
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										26
									
								
								nginx-allow-dynamicip/readme.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								nginx-allow-dynamicip/readme.md
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,26 @@
 | 
			
		||||
### NGINX ALLOW DYNAMIC IP
 | 
			
		||||
## Configure nginx config files to edit IP based on domain name
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# Requirements
 | 
			
		||||
`dig`
 | 
			
		||||
dig is most likely installed on your distro but incase it isn't install it first
 | 
			
		||||
 | 
			
		||||
# Usage
 | 
			
		||||
First, get the script and make it executable:
 | 
			
		||||
 | 
			
		||||
```bash
 | 
			
		||||
curl -O https://git.shihaam.dev/shihaam/sarmic/raw/branch/master/nginx-allow-dynamicip/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
 | 
			
		||||
 | 
			
		||||
```nginx
 | 
			
		||||
        #Block public access
 | 
			
		||||
        allow 1.1.1.1; #DYNAMIC
 | 
			
		||||
        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
 | 
			
		||||
`sudo ./nginx-allow-dynamicip.sh db-sarlinode.shihaam.dev home.shihaam.me`
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user