-
Notifications
You must be signed in to change notification settings - Fork 12
fix: serve security headers from app nginx instead of ingress custom-headers #4186
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
devthejo
wants to merge
3
commits into
master
Choose a base branch
from
fix/frontend-security-headers-in-nginx
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| # Security headers for the SPA. Included from nginx.conf at server level AND in | ||
| # every location block, because nginx drops inherited add_header directives in any | ||
| # location that defines its own — including it everywhere keeps a single source of truth. | ||
| add_header X-Frame-Options "deny" always; | ||
| add_header X-Content-Type-Options "nosniff" always; | ||
| add_header X-XSS-Protection "0" always; | ||
| add_header Referrer-Policy "strict-origin-when-cross-origin" always; | ||
| add_header Cache-Control "no-store" always; | ||
| add_header Content-Security-Policy "default-src 'none'; manifest-src 'self' https://*.gouv.fr; connect-src 'self' https://*.gouv.fr https://api.tally.so https://*.tally.so; font-src 'self' https://fonts.gstatic.com https://tally.so https://*.tally.so; img-src 'self' https://tally.so https://*.tally.so data:; script-src 'self' https://*.gouv.fr https://tally.so https://*.tally.so; frame-src 'self' https://*.gouv.fr https://tally.so https://*.tally.so; style-src 'self' 'unsafe-inline' https://*.gouv.fr https://tally.so https://*.tally.so" always; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| user nginx; | ||
| worker_processes auto; # it will be determinate automatically by the number of core | ||
|
|
||
| error_log /var/log/nginx/error.log warn; | ||
|
|
||
| events { | ||
| worker_connections 1024; | ||
| } | ||
|
|
||
|
|
||
| http { | ||
| server_tokens off; | ||
| absolute_redirect off; | ||
| access_log /var/log/nginx/access.log; | ||
| default_type application/octet-stream; | ||
| error_log /var/log/nginx/error.log; | ||
| include /etc/nginx/mime.types; | ||
| keepalive_timeout 3000; | ||
|
devthejo marked this conversation as resolved.
|
||
| sendfile on; | ||
|
|
||
| server { | ||
| listen 8080; | ||
| root /usr/share/nginx/html; | ||
| index index.html; | ||
| server_name_in_redirect on; | ||
|
|
||
| # Security headers served by the app itself, so they no longer depend on the | ||
| # ingress controller honouring nginx custom-headers annotations. nginx does not | ||
| # inherit add_header into a location that defines its own, so the headers are | ||
| # included in every location block below. This server-level include is only a | ||
| # fallback for requests matching no location (should not happen in practice). | ||
| include /etc/nginx/security-headers.conf; | ||
|
devthejo marked this conversation as resolved.
|
||
|
|
||
|
devthejo marked this conversation as resolved.
|
||
| charset utf-8; | ||
|
|
||
| gzip on; | ||
| gzip_disable "msie6"; | ||
| gzip_vary on; | ||
| gzip_proxied any; | ||
| gzip_comp_level 6; | ||
| gzip_buffers 16 8k; | ||
| gzip_http_version 1.1; | ||
| gzip_min_length 256; | ||
| gzip_types text/css application/json application/javascript application/x-javascript text/javascript application/vnd.ms-fontobject application/x-font-ttf font/opentype image/svg+xml image/x-icon; | ||
|
|
||
| client_max_body_size 32m; | ||
| error_page 500 502 503 504 /50x.html; | ||
|
|
||
| location / { | ||
| include /etc/nginx/security-headers.conf; | ||
| # this always fallback on /index.html, never 404 | ||
| try_files $uri $uri.html $uri/index.html $uri/ /index.html; | ||
| } | ||
|
|
||
| location /50x.html { | ||
| include /etc/nginx/security-headers.conf; | ||
| root /var/lib/nginx/html; | ||
| } | ||
|
|
||
| location /live { | ||
| include /etc/nginx/security-headers.conf; | ||
| default_type text/plain; | ||
| return 200 'OK'; | ||
| } | ||
|
|
||
| include /etc/nginx/ready_response.conf; | ||
| location /ready { | ||
| include /etc/nginx/security-headers.conf; | ||
| default_type text/plain; | ||
| if ($ready_response = 'OK') { | ||
| return 200 $ready_response; | ||
| } | ||
| return 500 'Not Ready'; | ||
| } | ||
|
|
||
| } | ||
| } | ||
|
devthejo marked this conversation as resolved.
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| # Security headers for the SPA. Included from nginx.conf at server level AND in | ||
| # every location block, because nginx drops inherited add_header directives in any | ||
| # location that defines its own — including it everywhere keeps a single source of truth. | ||
| add_header X-Frame-Options "deny" always; | ||
| add_header X-Content-Type-Options "nosniff" always; | ||
| add_header X-XSS-Protection "0" always; | ||
| add_header X-Robots-Tag "noindex, nofollow, nosnippet, noarchive" always; | ||
| add_header Referrer-Policy "strict-origin-when-cross-origin" always; | ||
| add_header Cache-Control "no-store" always; | ||
| add_header Content-Security-Policy "default-src 'none'; manifest-src 'self' https://*.gouv.fr; connect-src 'self' https://*.gouv.fr; font-src 'self'; img-src 'self' data:; script-src 'self' https://*.gouv.fr; frame-src 'self' https://*.gouv.fr; style-src 'self' 'unsafe-inline' https://*.gouv.fr" always; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| # Security headers for the SPA. Included from nginx.conf at server level AND in | ||
| # every location block, because nginx drops inherited add_header directives in any | ||
| # location that defines its own — including it everywhere keeps a single source of truth. | ||
| add_header X-Frame-Options "deny" always; | ||
| add_header X-Content-Type-Options "nosniff" always; | ||
| add_header X-XSS-Protection "0" always; | ||
| add_header Referrer-Policy "strict-origin-when-cross-origin" always; | ||
| add_header Cache-Control "no-store" always; | ||
| add_header Content-Security-Policy "default-src 'none'; manifest-src 'self' https://*.gouv.fr; connect-src 'self' https://*.gouv.fr https://api.tally.so https://*.tally.so; font-src 'self' https://fonts.gstatic.com https://tally.so https://*.tally.so; img-src 'self' https://tally.so https://*.tally.so data:; script-src 'self' https://*.gouv.fr https://tally.so https://*.tally.so; frame-src 'self' https://*.gouv.fr https://tally.so https://*.tally.so; style-src 'self' 'unsafe-inline' https://*.gouv.fr https://tally.so https://*.tally.so" always; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.