Skip to content

Commit

Permalink
[fix] Include allowed_hostnames in nginx Content-Security-Policy #366
Browse files Browse the repository at this point in the history
Fixes #366
  • Loading branch information
nemesifier committed May 22, 2024
1 parent f2735e6 commit 7bc4790
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
7 changes: 2 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1032,12 +1032,9 @@ Below are listed all the variables you can customize (you may also want to take
# nginx error log configuration
openwisp2_nginx_access_log: "{{ openwisp2_path }}/log/nginx.access.log"
openwisp2_nginx_error_log: "{{ openwisp2_path }}/log/nginx.error.log error"
# nginx Content Security Policy header
# nginx Content Security Policy header, customize if needed
openwisp2_nginx_csp: >
"default-src http: https: data: blob: 'unsafe-inline';
script-src 'unsafe-eval' https: 'unsafe-inline' 'self';
frame-ancestors 'self'; connect-src https://{{ inventory_hostname }} wss: 'self';
worker-src https://{{ inventory_hostname }} blob: 'self';" always;
CUSTOM_NGINX_SECURITY_POLICY
# uwsgi gid, omitted by default
openwisp2_uwsgi_gid: null
# number of uWSGI process to spawn. Default value is 1.
Expand Down
4 changes: 2 additions & 2 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ openwisp2_nginx_client_max_body_size: 20M
openwisp2_nginx_csp: >
"default-src http: https: data: blob: 'unsafe-inline';
script-src 'unsafe-eval' https: 'unsafe-inline' 'self';
frame-ancestors 'self'; connect-src https://{{ inventory_hostname }} wss: 'self';
worker-src https://{{ inventory_hostname }} blob: 'self';" always;
frame-ancestors 'self'; connect-src https://{{ inventory_hostname }}{% for host in openwisp2_allowed_hosts %} https://{{ host }}{% endfor %} wss: 'self';
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_install_ntp: true
Expand Down
1 change: 1 addition & 0 deletions tasks/nginx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
dest: "{{ openwisp2_path }}/nginx-conf/openwisp2/security.conf"
mode: 0644
notify: Restart nginx
tags: [nginx_security]

- name: Nginx site available
template:
Expand Down

0 comments on commit 7bc4790

Please sign in to comment.