Skip to content

Instantly share code, notes, and snippets.

@marians
Last active August 29, 2015 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save marians/7fdb15efc589f6c28b58 to your computer and use it in GitHub Desktop.
Save marians/7fdb15efc589f6c28b58 to your computer and use it in GitHub Desktop.
giantswarm.io nginx component as of 2015-02-17
FROM nginx
MAINTAINER Marian Steinbach <marian@giantswarm.io>
ADD content /content
RUN chown nginx -R /content
ADD nginx.conf /etc/nginx/nginx.conf
RUN rm /etc/nginx/conf.d/*
EXPOSE 80
ENTRYPOINT ["nginx"]
daemon off;
error_log stderr warn;
user nginx;
worker_processes 1;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
keepalive_timeout 5s;
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format custom '"$request" '
'$status $body_bytes_sent $request_time '
'"$remote_addr" "$http_x_forwarded_for" '
'"$http_user_agent" "$http_referer"';
proxy_cache_path /var/cache/nginx keys_zone=one:50m;
access_log /dev/stdout custom;
sendfile on;
gzip on;
gzip_proxied any;
gzip_types text/plain text/xml text/css
text/comma-separated-values
text/javascript application/javascript
application/atom+xml application/json
image/svg+xml;
upstream WEBAPP {
server webapp:8000;
}
server {
listen 80;
# pass on HTTP host name
proxy_set_header Host $http_host;
# pass on real client's IP
proxy_set_header X-Real-IP $http_x_forwarded_for;
# limit size of requests/responses to 100 MB
client_max_body_size 100000000;
chunked_transfer_encoding on;
# A name for the cache zone
proxy_cache one;
proxy_connect_timeout 5;
proxy_read_timeout 240;
root /content;
# Redirects for legacy URLs
rewrite ^/contact.html$ /contact/ permanent;
# we have some more of this. Removed for brevity.
location /favicon.ico {}
location /robots.txt {}
location /humans.txt {}
# handle error pages directly
location /_error {
internal;
}
location / {
proxy_pass http://WEBAPP;
# Error pages
proxy_intercept_errors on;
error_page 403 /_error/403.html;
error_page 404 /_error/404.html;
error_page 500 502 503 504 /_error/50x.html;
}
location /static {
# General expires header for static files
expires 100d;
# cache everything for 1 hour
proxy_cache_valid any 60m;
# cache everything from the first request
proxy_cache_min_uses 1;
# Cache 404 error responses for a shorter time
proxy_cache_valid 404 10m;
proxy_pass http://WEBAPP;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment