Created
November 4, 2014 14:03
-
-
Save stucchio/54331ebdee08bcadd051 to your computer and use it in GitHub Desktop.
dockerfile for nginx reverse proxy
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
FROM ubuntu:14.04 | |
MAINTAINER Chris Stucchio <[email protected]> | |
# Nginx | |
RUN apt-get update && apt-get install -y nginx nginx-extras && mkdir /var/www | |
ADD nginx.conf /etc/nginx/nginx.conf | |
ADD run_nginx.sh /bin/run_nginx.sh | |
RUN chmod +x /bin/run_nginx.sh |
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
user www-data; | |
worker_processes 4; | |
pid /run/nginx.pid; | |
daemon off; #To run in docker | |
events { | |
worker_connections 768; | |
# multi_accept on; | |
} | |
http { | |
## | |
# Basic Settings | |
## | |
sendfile on; | |
tcp_nopush on; | |
tcp_nodelay on; | |
keepalive_timeout 65; | |
types_hash_max_size 2048; | |
# server_tokens off; | |
# server_names_hash_bucket_size 64; | |
# server_name_in_redirect off; | |
include /etc/nginx/mime.types; | |
default_type application/octet-stream; | |
## | |
# Logging Settings | |
## | |
access_log /var/log/nginx/access.log; | |
error_log /var/log/nginx/error.log; | |
## | |
# Gzip Settings | |
## | |
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_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript; | |
## | |
# nginx-naxsi config | |
## | |
# Uncomment it if you installed nginx-naxsi | |
## | |
#include /etc/nginx/naxsi_core.rules; | |
## | |
# nginx-passenger config | |
## | |
# Uncomment it if you installed nginx-passenger | |
## | |
#passenger_root /usr; | |
#passenger_ruby /usr/bin/ruby; | |
## | |
# Virtual Host Configs | |
## | |
server { | |
server_name localhost; | |
} | |
server { | |
listen 8888 default_server; | |
server_name localhost; | |
location ^~ / { | |
alias /var/www/; # Static media | |
add_header Cache-Control public; | |
expires 1h; | |
gzip on; #Gzip content dynamically | |
gzip_min_length 1000; | |
gzip_proxied expired no-cache no-store private auth; | |
gzip_types text/plain application/xml application/javascript application/json image/svg+xml text/css application/x-javascript; | |
gzip_disable "MSIE [1-6]\."; | |
} | |
location ^~ /api { | |
proxy_set_header Host $host; | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_pass http://PHOST:PPORT/api/; | |
gzip on; #Gzip content dynamically | |
gzip_min_length 1000; | |
gzip_proxied expired no-cache no-store private auth; | |
gzip_types text/plain application/xml application/javascript application/json; | |
gzip_disable "MSIE [1-6]\."; | |
} | |
} | |
} | |
#mail { | |
# # See sample authentication script at: | |
# # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript | |
# | |
# # auth_http localhost/auth.php; | |
# # pop3_capabilities "TOP" "USER"; | |
# # imap_capabilities "IMAP4rev1" "UIDPLUS"; | |
# | |
# server { | |
# listen localhost:110; | |
# protocol pop3; | |
# proxy on; | |
# } | |
# | |
# server { | |
# listen localhost:143; | |
# protocol imap; | |
# proxy on; | |
# } | |
#} |
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
#!/bin/bash | |
/bin/sed -i "s/PHOST/${WEB_PORT_8000_TCP_ADDR}/g" /etc/nginx/nginx.conf | |
/bin/sed -i "s/PPORT/${WEB_PORT_8000_TCP_PORT}/g" /etc/nginx/nginx.conf | |
/usr/sbin/nginx |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment