github.com/misfo/deis@v1.0.1-0.20141111224634-e0eee0392b8a/router/templates/nginx.conf (about) 1 # required to run in a container 2 daemon off; 3 4 user www-data; 5 worker_processes auto; 6 pid /run/nginx.pid; 7 8 events { 9 worker_connections 768; 10 # multi_accept on; 11 } 12 13 http { 14 # basic settings 15 sendfile on; 16 tcp_nopush on; 17 tcp_nodelay on; 18 keepalive_timeout 65; 19 types_hash_max_size 2048; 20 server_names_hash_bucket_size 64; 21 22 include /opt/nginx/conf/mime.types; 23 default_type application/octet-stream; 24 {{ if .deis_router_gzip }} 25 gzip {{ .deis_router_gzip }}; 26 gzip_comp_level {{ or .deis_router_gzipCompLevel "5" }}; 27 gzip_disable {{ or .deis_router_gzipDisable "\"msie6\"" }}; 28 gzip_http_version {{ or .deis_router_gzipHttpVersion "1.1" }}; 29 gzip_min_length {{ or .deis_router_gzipMinLength "256" }}; 30 gzip_types {{ or .deis_router_gzipTypes "application/atom+xml application/javascript application/json application/rss+xml application/vnd.ms-fontobject application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/svg+xml image/x-icon text/css text/plain text/x-component" }}; 31 gzip_proxied {{ or .deis_router_gzipProxied "any" }}; 32 gzip_vary {{ or .deis_router_gzipVary "on" }}; 33 {{ end }} 34 client_max_body_size {{ or (.deis_router_bodySize) "1m" }}; 35 36 # send logs to STDOUT so they can be seen using 'docker logs' 37 access_log /opt/nginx/logs/access.log; 38 error_log /opt/nginx/logs/error.log; 39 40 map $http_upgrade $connection_upgrade { 41 default upgrade; 42 '' close; 43 } 44 45 ## start deis-controller 46 {{ if .deis_controller_host }} 47 upstream deis-controller { 48 server {{ .deis_controller_host }}:{{ .deis_controller_port }}; 49 } 50 51 server { 52 server_name ~^deis\.(?<domain>.+)$; 53 include deis.conf; 54 55 location / { 56 proxy_buffering off; 57 proxy_set_header Host $host; 58 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 59 proxy_redirect off; 60 proxy_connect_timeout {{ or (.deis_router_controller_timeout_connect) "10s" }}; 61 proxy_send_timeout {{ or (.deis_router_controller_timeout_send) "20m" }}; 62 proxy_read_timeout {{ or (.deis_router_controller_timeout_read) "20m" }}; 63 64 proxy_pass http://deis-controller; 65 } 66 }{{ end }} 67 ## end deis-controller 68 69 ## start deis-store-gateway 70 {{ if .deis_store_gateway_host }} 71 upstream deis-store-gateway { 72 server {{ .deis_store_gateway_host }}:{{ .deis_store_gateway_port }}; 73 } 74 75 server { 76 server_name ~^deis-store\.(?<domain>.+)$; 77 include deis.conf; 78 79 client_max_body_size 0; 80 81 location / { 82 proxy_buffering off; 83 proxy_set_header Host $host; 84 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 85 proxy_redirect off; 86 proxy_connect_timeout 10s; 87 proxy_send_timeout 1200s; 88 proxy_read_timeout 1200s; 89 90 proxy_pass http://deis-store-gateway; 91 } 92 }{{ end }} 93 ## end deis-store-gateway 94 95 ## start service definitions for each application 96 {{ $useSSL := or .deis_router_sslCert "false" }} 97 {{ $domains := .deis_domains }}{{ range $service := .deis_services }}{{ if $service.Nodes }} 98 upstream {{ Base $service.Key }} { 99 {{ range $upstream := $service.Nodes }}server {{ $upstream.Value }}; 100 {{ end }} 101 } 102 103 server { 104 server_name ~^{{ Base $service.Key }}\.(?<domain>.+)${{ range $app_domains := $domains }}{{ if eq (Base $service.Key) (Base $app_domains.Key) }} {{ $app_domains.Value }}{{ end }}{{ end }}; 105 include deis.conf; 106 107 location / { 108 proxy_buffering off; 109 proxy_set_header Host $host; 110 {{ if ne $useSSL "false" }} 111 proxy_set_header X-Forwarded-Proto $scheme; 112 {{ end }} 113 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 114 proxy_redirect off; 115 proxy_connect_timeout 10s; 116 proxy_send_timeout 1200s; 117 proxy_read_timeout 1200s; 118 proxy_http_version 1.1; 119 proxy_set_header Upgrade $http_upgrade; 120 proxy_set_header Connection $connection_upgrade; 121 122 proxy_next_upstream error timeout http_502 http_503 http_504; 123 124 add_header X-Deis-Upstream $upstream_addr; 125 126 proxy_pass http://{{ Base $service.Key }}; 127 } 128 } 129 {{ end }}{{ end }} 130 ## end service definitions for each application 131 132 # healthcheck 133 server { 134 listen 80 default_server; 135 location /health-check { 136 default_type 'text/plain'; 137 access_log off; 138 return 200; 139 } 140 } 141 } 142 143 ## start builder 144 {{ if .deis_builder_host }} 145 tcp { 146 access_log /opt/nginx/logs/git.log; 147 tcp_nodelay on; 148 timeout {{ or (.deis_router_builder_timeout_tcp) "1200000" }}; 149 150 # same directive names, but these are in miliseconds... 151 proxy_connect_timeout {{ or (.deis_router_builder_timeout_connect) "10000" }}; 152 proxy_send_timeout {{ or (.deis_router_builder_timeout_send) "1200000" }}; 153 proxy_read_timeout {{ or (.deis_router_builder_timeout_read) "1200000" }}; 154 155 upstream builder { 156 server {{ .deis_builder_host }}:{{ .deis_builder_port }}; 157 } 158 159 server { 160 listen 2222; 161 proxy_pass builder; 162 } 163 }{{ end }} 164 ## end builder