Skip to content
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

[fix] Include allowed_hostnames in nginx Content-Security-Policy #366 #474

Merged
merged 2 commits into from
May 22, 2024
Merged
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
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ jobs:
run: |
pip install molecule molecule-plugins[docker] yamllint ansible-lint docker
pip install openwisp-utils[qa]
# https://github.com/ansible-community/molecule-plugins/issues/256
python -m pip install 'requests<2.32'

- name: Install Ansible Galaxy dependencies
run: ansible-galaxy collection install "community.general:>=3.6.0"
Expand Down
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
Loading