mirror of
https://github.com/idanoo/m2.nz.git
synced 2024-11-22 00:11:51 +00:00
Update nginx updates
This commit is contained in:
parent
9dcda822a8
commit
317b3369ed
@ -10,7 +10,7 @@ Note this is for Ubuntu/Nginx but may work on other systems.
|
|||||||
Install required packages & add to nginx config.
|
Install required packages & add to nginx config.
|
||||||
The GeoIP DB will be under /usr/shared/GeoIP/GeoIPv6.dat (Or GeoIP.dat for v4 only):
|
The GeoIP DB will be under /usr/shared/GeoIP/GeoIPv6.dat (Or GeoIP.dat for v4 only):
|
||||||
```shell
|
```shell
|
||||||
apt install -y libnginx-mod-http-geoip geoip-database
|
sudo apt install -y libnginx-mod-http-geoip geoip-database
|
||||||
echo 'geoip_country /usr/share/GeoIP/GeoIPv6.dat;' > /etc/nginx/conf.d/geoip.conf
|
echo 'geoip_country /usr/share/GeoIP/GeoIPv6.dat;' > /etc/nginx/conf.d/geoip.conf
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -25,7 +25,7 @@ map $geoip_country_code $allowed_country {
|
|||||||
|
|
||||||
Then we need to add a simple check in our site vhost inside the `server {` block, but before the `location /` block:
|
Then we need to add a simple check in our site vhost inside the `server {` block, but before the `location /` block:
|
||||||
```shell
|
```shell
|
||||||
# /etc/nginx/sites-enabled/your_site.conf
|
# /etc/nginx/sites-enabled/site.conf or /etc/nginx/conf.d/site.conf
|
||||||
if ($allowed_country = no) {
|
if ($allowed_country = no) {
|
||||||
return 403;
|
return 403;
|
||||||
}
|
}
|
||||||
@ -33,7 +33,7 @@ if ($allowed_country = no) {
|
|||||||
|
|
||||||
Quick reload and boom! Done!
|
Quick reload and boom! Done!
|
||||||
```shell
|
```shell
|
||||||
systemctl reload nginx
|
sudo systemctl reload nginx
|
||||||
```
|
```
|
||||||
|
|
||||||
Based off an older gist found on [Github here](https://gist.github.com/dunderrrrrr/8d3fced1f73de2d70ede38f39c88d215)
|
Based off an older gist found on [Github here](https://gist.github.com/dunderrrrrr/8d3fced1f73de2d70ede38f39c88d215)
|
||||||
|
Loading…
Reference in New Issue
Block a user