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

Add Security headers to Nginx #1

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 docker/nginx/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
FROM nginx:latest

COPY config/security.conf /etc/nginx/security.conf
COPY config/nginx.conf /etc/nginx/nginx.conf
COPY config/sites-available/* /etc/nginx/sites-available/
COPY docker-entrypoint.sh /entrypoint.sh
Expand Down
22 changes: 21 additions & 1 deletion docker/nginx/config/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,28 @@ error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;

events {
worker_connections 1024;
multi_accept on;
worker_connections 1024;
}

http {
log_not_found off;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Attention à l'indentation ici

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad

server_tokens off;
tcp_nodelay on;
charset utf-8;
tcp_nopush on;

resolver 1.1.1.1 1.0.0.1 8.8.8.8 8.8.4.4 208.67.222.222 208.67.220.220 valid=60s;
resolver_timeout 2s;

ssl_ciphers TLS_AES_256_GCM_SHA384:TLS_AES_128_GCM_SHA256:TLS_CHACHA20_POLY1305_SHA256;
ssl_session_cache shared:SSL:10m;
ssl_session_tickets off;
ssl_stapling_verify on;
ssl_protocols TLSv1.3;
ssl_session_timeout 1d;
ssl_stapling on;

include /etc/nginx/mime.types;
default_type application/octet-stream;

Expand All @@ -35,7 +53,9 @@ http {
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;

client_max_body_size 2M;
types_hash_max_size 2048;

include /etc/nginx/security.conf;
include /etc/nginx/conf.d/*conf;
include /etc/nginx/sites-enabled/*;
}
6 changes: 6 additions & 0 deletions docker/nginx/config/security.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
add_header Content-Security-Policy "default-src 'self'; script-src 'self'; style-src 'self'; img-src 'self'; object-src 'self'; frame-src 'self'; frame-ancestors 'none'; upgrade-insecure-requests; reflected-xss block; referrer no-referrer" always;
add_header Referrer-Policy "no-referrer" always;
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always;
add_header X-Content-Type-Options "nosniff" always;
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-XSS-Protection "1; mode=block" always;
2 changes: 2 additions & 0 deletions docker/nginx/config/sites-available/local.api.ideka.fr
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ server {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;
fastcgi_buffers 8 16k;
fastcgi_buffer_size 32k;
}

# return 404 for all other php files not matching the front controller
Expand Down
6 changes: 0 additions & 6 deletions ideka.dist.env

This file was deleted.