Skip to content
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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1868,11 +1868,11 @@ Sets the bucket size for the server names hash tables. This is needed when you h

##### `NGINX_HSTS_ENABLED`

Advanced configuration option for turning off the HSTS configuration. Applicable only when SSL is in use. Defaults to `true`. See [#138](https://github.com/sameersbn/docker-gitlab/issues/138) for use case scenario.
Advanced configuration option for turning off HSTS for the GitLab and GitLab Pages nginx virtual hosts. Applicable only when SSL is in use. Defaults to `true`. See [#138](https://github.com/sameersbn/docker-gitlab/issues/138) for use case scenario.

##### `NGINX_HSTS_MAXAGE`

Advanced configuration option for setting the HSTS max-age in the gitlab nginx vHost configuration. Applicable only when SSL is in use. Defaults to `31536000`.
Advanced configuration option for setting the HSTS max-age in the GitLab and GitLab Pages nginx virtual hosts. Applicable only when SSL is in use. Defaults to `31536000`.

##### `NGINX_PROXY_BUFFERING`

Expand Down
1 change: 1 addition & 0 deletions assets/runtime/config/nginx/gitlab-pages
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ server {
## Individual nginx logs for GitLab pages
access_log {{GITLAB_LOG_DIR}}/nginx/gitlab_pages_access.log;
error_log {{GITLAB_LOG_DIR}}/nginx/gitlab_pages_error.log;
add_header Strict-Transport-Security "max-age={{NGINX_HSTS_MAXAGE}}";
location / {
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
Expand Down
2 changes: 2 additions & 0 deletions assets/runtime/config/nginx/gitlab-pages-ssl
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ server {
server_name ~^.*{{GITLAB_PAGES_DOMAIN}};
server_tokens off; ## Don't show the nginx version number, a security best practice

add_header Strict-Transport-Security "max-age={{NGINX_HSTS_MAXAGE}}";

## Strong SSL Security
## https://raymii.org/s/tutorials/Strong_SSL_Security_On_nginx.html & https://cipherli.st/
ssl_certificate {{SSL_PAGES_CERT_PATH}};
Expand Down
4 changes: 4 additions & 0 deletions assets/runtime/functions
Original file line number Diff line number Diff line change
Expand Up @@ -1656,6 +1656,9 @@ nginx_configure_pages(){
if [[ ${GITLAB_PAGES_ENABLED} == true ]]; then
echo "Configuring nginx::gitlab-pages..."
if [[ ${GITLAB_PAGES_NGINX_PROXY} == true ]]; then
if [[ ${GITLAB_PAGES_HTTPS} != true || ${NGINX_HSTS_ENABLED} != true ]]; then
sed -i "/{{NGINX_HSTS_MAXAGE}}/d" ${GITLAB_PAGES_NGINX_CONFIG}
fi
if [[ ${GITLAB_PAGES_HTTPS} == true ]]; then
update_template ${GITLAB_PAGES_NGINX_CONFIG} \
GITLAB_PORT \
Expand All @@ -1668,6 +1671,7 @@ nginx_configure_pages(){
SSL_PAGES_CIPHERS \
SSL_PAGES_PROTOCOLS \
SSL_DHPARAM_PATH \
NGINX_HSTS_MAXAGE \
GITLAB_LOG_DIR
else
update_template ${GITLAB_PAGES_NGINX_CONFIG} \
Expand Down