Skip to content

[fix] Nginx config location admin/ allowed network list #519

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ openwisp2_nginx_csp: >
worker-src https://{{ inventory_hostname }}{% for host in openwisp2_allowed_hosts %} https://{{ host }}{% endfor %} blob: 'self';" always;
openwisp2_uwsgi_gid: null
openwisp2_admin_allowed_network: null
openwisp2_admin_allowed_networks: []
openwisp2_install_ntp: true
openwisp2_sentry:
dsn: false
Expand Down
7 changes: 4 additions & 3 deletions docs/user/role-variables.rst
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,11 @@ take a look at `the default values of these variables
openwisp2_daphne_processes: 2
# maximum time to allow a websocket to be connected (in seconds)
openwisp2_daphne_websocket_timeout: 1800
# the following setting controls which ip address range
# is allowed to access the openwisp2 admin web interface
# the following setting controls which ip address ranges
# are allowed to access the openwisp2 admin web interface
# (by default any IP is allowed)
openwisp2_admin_allowed_network: null
openwisp2_admin_allowed_networks:
- "192.168.1.0/24"
# install ntp client (enabled by default)
openwisp2_install_ntp: true
# if you have any custom supervisor service, you can
Expand Down
7 changes: 6 additions & 1 deletion templates/nginx/site-conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,15 @@ server {
proxy_set_header X-Forwarded-Host $server_name;
}

{% if openwisp2_admin_allowed_network %}
{% if openwisp2_admin_allowed_network or openwisp2_admin_allowed_networks %}
location /admin/ {
try_files {{ openwisp2_path }}/public_html/maintenance.html $uri @uwsgi;
{% if openwisp2_admin_allowed_network %}
allow {{ openwisp2_admin_allowed_network }};
{% endif %}
{% for network in openwisp2_admin_allowed_networks %}
allow {{ network }};
{% endfor %}
deny all;
}
{% endif %}
Expand Down