daemon off;
user nginx nginx;
pid /var/run/nginx.pid;
worker_processes auto;
events {
use epoll;
}
# Logging to stderr enables better integration with Docker and GKE/Kubernetes.
error_log stderr warn;
http {
include /etc/nginx/mime.types;
server_tokens off;
# HTTP subrequests
endpoints_resolver 8.8.8.8;
endpoints_certificates /etc/nginx/trusted-ca-certificates.crt;
set_real_ip_from 0::/0;
real_ip_header X-Forwarded-For;
real_ip_recursive on;
# Format log as json for nice integration with StackDriver
log_format trace escape=json
'{'
# This one is picked up specifically by StackDriver and shown as the headline of the log entry
'"message": "$uri",'
'"http_response_code": "$status",'
'"http_method":"$request_method",'
'"http_user_agent":"$http_user_agent",'
'"http_referrer":"$http_referer",'
'"request_size_in_bytes":"$request_length",'
'"response_size_in_bytes":"$bytes_sent",'
'"X-Request-ID":"$http_x_request_id",'
'"X-Parent-Request-ID":"$http_x_parent_request_id"'
'}';
server {
# Desperately try to get rid of those 'buffering' warnings, does not seem to work so far.
client_max_body_size 10M;
client_body_buffer_size 512M;
server_name "";
# don't send the nginx version number in error pages and Server header
server_tokens off;
listen 9001 ssl backlog=16384;
listen 9000 http2 ssl backlog=16384;
ssl_certificate /etc/nginx/ssl/fullchain.pem;
ssl_certificate_key /etc/nginx/ssl/privkey.pem;
# make the server choose the best cipher instead of the browser
# Perfect Forward Secrecy(PFS) is frequently compromised without this
ssl_prefer_server_ciphers on;
# support only believed secure ciphersuites using the following priority:
# 1.) prefer PFS enabled ciphers
# 2.) prefer AES128 over AES256 for speed (AES128 has completely adequate security for now)
# 3.) Support DES3 for IE8 support
#
# disable the following ciphersuites completely
# 1.) null ciphers
# 2.) ciphers with low security
# 3.) fixed ECDH cipher (does not allow for PFS)
# 4.) known vulnerable cypers (MD5, RC4, etc)
# 5.) little-used ciphers (Camellia, Seed)
ssl_ciphers 'kEECDH+ECDSA+AES128 kEECDH+ECDSA+AES256 kEECDH+AES128 kEECDH+AES256 kEDH+AES128 kEDH+AES256 DES-CBC3-SHA +SHA !aNULL !eNULL !LOW !kECDH !DSS !MD5 !EXP !PSK !SRP !CAMELLIA !SEED !3DES !SHA1';
# Use 2048 bit Diffie-Hellman RSA key parameters
# (otherwise Nginx defaults to 1024 bit, lowering the strength of encryption # when using PFS)
# Generated by OpenSSL with the following command:
# openssl dhparam -outform pem -out /etc/nginx/ssl/dhparam2048.pem 2048
ssl_dhparam /etc/nginx/custom/dhparam2048.pem;
# Cache SSL Sessions for up to 10 minutes
# This improves performance by avoiding the costly session negotiation process where possible
ssl_session_cache builtin:1000 shared:SSL:10m;
ssl_session_timeout 10m;
ssl_session_tickets off; # Requires nginx >= 1.5.9
# google domain verification (in order to use PubSub push notifications we have
# to prove ownership of the target URL)
location /google8b0fc1b90cdd1d3d.html { alias /etc/nginx/google-domain-verification.html; }
access_log /dev/stdout trace;
location / {
# Enable CORS
add_header Access-Control-Allow-Methods 'GET,OPTIONS,PUT,POST,DELETE' always;
add_header Access-Control-Allow-Credentials 'true' always;
add_header Access-Control-Allow-Origin '$http_origin' always;
add_header Access-Control-Allow-Headers 'Access-Control-Allow-Origin,Authorization,DNT,User-Agent,Keep-Alive,Content-Type,accept,origin,X-Requested-With' always;
# when serving user-supplied content, include a X-Content-Type-Options: nosniff header along with the Content-Type: header,
# to disable content-type sniffing on some browsers.
add_header X-Content-Type-Options 'nosniff';
add_header Cache-Control 'no-cache, no-store, must-revalidate';
add_header Cache-Pragma 'no-cache';
# This is dynamic content, so should never be cached.
expires -1;
# The AppSec scan says we need to define these headers. They're not really relevant for APIs serving nothing but json
# but doesn't do any harm, so added here to silence the AppSec tests.
add_header Content-Security-Policy 'script-src \'self\'';
add_header X-XSS-Protection '1; mode=block;';
add_header Strict-Transport-Security 'max-age=86400; includeSubDomains';
add_header X-Frame-Options "DENY";
if ($request_method = OPTIONS ) {
return 200;
}
# Begin Endpoints v2 Support
endpoints {
on;
server_config /etc/nginx/server_config.pb.txt;
api /etc/nginx/endpoints/service.json;
}
# End Endpoints v2 Support
# WARNING: only first backend is used
}
include /var/lib/nginx/extra/*.conf;
}
server {
# expose /nginx_status and /endpoints_status but on a different port to
# avoid external visibility / conflicts with the app.
listen 8090;
location /nginx_status {
stub_status on;
access_log off;
}
location /endpoints_status {
endpoints_status;
access_log off;
}
location /healthz {
return 200;
access_log off;
}
location / {
root /dev/null;
}
}
}