Skip to content

Commit

Permalink
NGX-903: Redirect non-VPN /goaccess requests to Central (#76)
Browse files Browse the repository at this point in the history
  • Loading branch information
combssm authored Jul 30, 2024
1 parent 6efd2d5 commit 085dae9
Showing 1 changed file with 18 additions and 33 deletions.
51 changes: 18 additions & 33 deletions templates/etc/nginx/conf.d/site.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
# {{ ansible_managed }}
# tags: site.conf.j2

geo $inmotion_ip {
default 0;
{% for ip in goaccess_allow_ips %}
{{ ip }} 1;
{% endfor %}
}

{% if site_domain != ansible_nodename %}
server {
Expand Down Expand Up @@ -63,20 +69,13 @@ server {

{% if goaccess_enabled is defined and goaccess_enabled | bool %}
location /goaccess {
if ($inmotion_ip = 0) {
return 301 https://central.inmotionhosting.com;
}

root /usr/share/nginx/html;
try_files $uri/report.html =404;

satisfy any;

{% for ip in goaccess_allow_ips %}
allow {{ ip }};
{% endfor %}

deny all;

auth_basic "Login Required";
auth_basic_user_file /etc/nginx/.htpasswd;

location /goaccess/ws {
proxy_pass_header Upgrade;
proxy_pass https://localhost:7890;
Expand Down Expand Up @@ -230,20 +229,13 @@ server {

{% if site_domain == ansible_nodename and goaccess_enabled is defined and goaccess_enabled | bool %}
location /goaccess {
if ($inmotion_ip = 0) {
return 301 https://central.inmotionhosting.com;
}

root /usr/share/nginx/html;
try_files $uri/report.html =404;

satisfy any;

{% for ip in goaccess_allow_ips %}
allow {{ ip }};
{% endfor %}

deny all;

auth_basic "Login Required";
auth_basic_user_file /etc/nginx/.htpasswd;

location /goaccess/ws {
proxy_pass_header Upgrade;
proxy_pass https://localhost:7890;
Expand Down Expand Up @@ -389,19 +381,12 @@ server {

{% if site_domain == ansible_nodename and goaccess_enabled is defined and goaccess_enabled | bool %}
location /goaccess {
if ($inmotion_ip = 0) {
return 301 https://central.inmotionhosting.com;
}

root /usr/share/nginx/html;
try_files $uri/report.html =404;

satisfy any;

{% for ip in goaccess_allow_ips %}
allow {{ ip }};
{% endfor %}

deny all;

auth_basic "Login Required";
auth_basic_user_file /etc/nginx/.htpasswd;

location /goaccess/ws {
proxy_pass_header Upgrade;
Expand Down

0 comments on commit 085dae9

Please sign in to comment.