|
| 1 | +daemon off; |
| 2 | +error_log /dev/stdout info; |
| 3 | +worker_processes auto; |
| 4 | +pid /var/run/nginx.pid; |
| 5 | +user kbmodule; |
| 6 | + |
| 7 | +events { |
| 8 | + worker_connections 256; |
| 9 | + # multi_accept on; |
| 10 | +} |
| 11 | + |
| 12 | +http { |
| 13 | + sendfile on; |
| 14 | + tcp_nopush on; |
| 15 | + tcp_nodelay on; |
| 16 | + keepalive_timeout 65; |
| 17 | + types_hash_max_size 2048; |
| 18 | + |
| 19 | + include /etc/nginx/mime.types; |
| 20 | + default_type application/octet-stream; |
| 21 | + |
| 22 | + ## |
| 23 | + # Logging Settings |
| 24 | + ## |
| 25 | + |
| 26 | + # Always log to the logfiles, and default errors to stderr, with access logs to syslog and stdout |
| 27 | + # as optional |
| 28 | + |
| 29 | + # If the template is passed an nginx syslog path via nginx_log_syslog env var, log to there |
| 30 | + {{ if .Env.nginx_log_syslog }} |
| 31 | + access_log {{ .Env.nginx_log_syslog }} combined; |
| 32 | + {{ end }} |
| 33 | + # If nginx_log_stdout env var isn't false or empty, log to stdout |
| 34 | + {{ if isTrue (default .Env.nginx_log_stdout "true") }} |
| 35 | + access_log /dev/stdout; |
| 36 | + {{ end }} |
| 37 | + access_log /var/log/nginx/access.log; |
| 38 | + |
| 39 | + {{ if isTrue (default .Env.nginx_log_stderr "true") }} |
| 40 | + error_log /dev/stderr {{ default .Env.nginx_loglevel "error" }}; |
| 41 | + {{ end }} |
| 42 | + error_log /var/log/nginx/error.log {{ default .Env.nginx_loglevel "error" }}; |
| 43 | + |
| 44 | + ## |
| 45 | + # Gzip settings |
| 46 | + ## |
| 47 | + gzip on; |
| 48 | + gzip_vary on; |
| 49 | + gzip_min_length 10240; |
| 50 | + gzip_proxied expired no-cache no-store private auth; |
| 51 | + gzip_types text/plain text/css text/xml text/javascript application/json application/x-javascript application/xml; |
| 52 | + gzip_disable "MSIE [1-6]\."; |
| 53 | + |
| 54 | + upstream docs { |
| 55 | + server docs.kbase.us:443; |
| 56 | + } |
| 57 | + |
| 58 | + upstream marketing { |
| 59 | + server kbs.comradeserver.com:443; |
| 60 | + } |
| 61 | + |
| 62 | + upstream outreach { |
| 63 | + server www.kbase.us:443; |
| 64 | + } |
| 65 | + |
| 66 | + upstream outreach2 { |
| 67 | + server kbase.us:443; |
| 68 | + } |
| 69 | + |
| 70 | + server { |
| 71 | + listen {{ default .Env.nginx_listen "80"}}; |
| 72 | + server_name {{ default .Env.nginx_server_name "localhost" }}; |
| 73 | + |
| 74 | + location / { |
| 75 | + # Ensure that index.html is invoked even if a path is |
| 76 | + # specified and doesn't exist. |
| 77 | + try_files $uri /$uri /index.html; |
| 78 | + # index index.html; |
| 79 | + ssi_silent_errors off; |
| 80 | + allow all; |
| 81 | + # this ensures that a downstream cache service will revalidate. |
| 82 | + add_header Cache-Control 'no-cache'; |
| 83 | + |
| 84 | + root /kb/deployment/services/kbase-ui/dist; |
| 85 | + } |
| 86 | + |
| 87 | + # Format is /__poke/https://www.example.com/some/path |
| 88 | + location ~* ^/__poke/docs/(.*)$ { |
| 89 | + # return 200 "Match found Capture Groups 1: $1 2: $2\n"; |
| 90 | + proxy_hide_header Content-Security-Policy; |
| 91 | + proxy_hide_header X-Content-Security-Policy; |
| 92 | + proxy_hide_header X-Webkit-Csp; |
| 93 | + proxy_pass https://docs/$1; |
| 94 | + proxy_http_version 1.1; |
| 95 | + proxy_set_header Connection ""; |
| 96 | + client_max_body_size 300M; |
| 97 | + proxy_buffer_size 128k; |
| 98 | + proxy_buffers 4 256k; |
| 99 | + proxy_busy_buffers_size 256k; |
| 100 | + proxy_set_header Host docs.kbase.us; |
| 101 | + proxy_intercept_errors on; |
| 102 | + recursive_error_pages on; |
| 103 | + error_page 301 302 307 = @handle_redirect_docs; |
| 104 | + } |
| 105 | + |
| 106 | + location @handle_redirect_docs { |
| 107 | + set $saved_redirect_location '$upstream_http_location'; |
| 108 | + # return 200 "Redirected $upstream_http_location\n"; |
| 109 | + # These header fields are massive in gitbook. |
| 110 | + proxy_hide_header Content-Security-Policy; |
| 111 | + proxy_hide_header X-Content-Security-Policy; |
| 112 | + proxy_hide_header X-Webkit-Csp; |
| 113 | + proxy_http_version 1.1; |
| 114 | + proxy_set_header Connection ""; |
| 115 | + client_max_body_size 300M; |
| 116 | + proxy_buffer_size 128k; |
| 117 | + proxy_buffers 4 256k; |
| 118 | + proxy_busy_buffers_size 256k; |
| 119 | + proxy_set_header Host docs.kbase.us; |
| 120 | + proxy_pass $saved_redirect_location; |
| 121 | + proxy_intercept_errors on; |
| 122 | + recursive_error_pages on; |
| 123 | + error_page 301 302 307 = @handle_redirect_docs; |
| 124 | + } |
| 125 | + |
| 126 | + location ~* ^/__poke/outreach/(.*)$ { |
| 127 | + # return 200 "Match found Capture Groups 1: $1 2: $2\n"; |
| 128 | + |
| 129 | + proxy_pass https://outreach/$1; |
| 130 | + proxy_http_version 1.1; |
| 131 | + proxy_set_header Connection ""; |
| 132 | + client_max_body_size 300M; |
| 133 | + proxy_set_header Host www.kbase.us; |
| 134 | + proxy_intercept_errors on; |
| 135 | + recursive_error_pages on; |
| 136 | + error_page 301 302 307 = @handle_redirect_outreach; |
| 137 | + } |
| 138 | + |
| 139 | + location @handle_redirect_outreach { |
| 140 | + # return 200 "Redirected $upstream_http_location\n"; |
| 141 | + # resolver 8.8.8.8; |
| 142 | + set $saved_redirect_location '$upstream_http_location'; |
| 143 | + proxy_http_version 1.1; |
| 144 | + proxy_set_header Connection ""; |
| 145 | + client_max_body_size 300M; |
| 146 | + proxy_set_header Host www.kbase.us; |
| 147 | + if ($saved_redirect_location ~* ^/) { |
| 148 | + proxy_pass https://outreach$saved_redirect_location; |
| 149 | + } |
| 150 | + if ($saved_redirect_location ~* ^https://www.kbase.us/(.*)$) { |
| 151 | + proxy_pass https://outreach/$1; |
| 152 | + } |
| 153 | + if ($saved_redirect_location ~* ^https://kbase.us/(.*)$) { |
| 154 | + proxy_pass https://outreach2/$1; |
| 155 | + } |
| 156 | + # if ($saved_redirect_location ~* ^https) { |
| 157 | + # proxy_pass $saved_redirect_location; |
| 158 | + # } |
| 159 | + proxy_intercept_errors on; |
| 160 | + recursive_error_pages on; |
| 161 | + error_page 301 302 307 = @handle_redirect_outreach; |
| 162 | + } |
| 163 | + |
| 164 | + location ~* ^/__poke/marketing/(.*)$ { |
| 165 | + # return 200 "Match found Capture Groups 1: $1 2: $2\n"; |
| 166 | + proxy_pass https://marketing/$1; |
| 167 | + proxy_http_version 1.1; |
| 168 | + proxy_set_header Connection ""; |
| 169 | + client_max_body_size 300M; |
| 170 | + proxy_set_header Host kbs.comradeserver.com; |
| 171 | + proxy_intercept_errors on; |
| 172 | + recursive_error_pages on; |
| 173 | + error_page 301 302 307 = @handle_redirect_marketing; |
| 174 | + } |
| 175 | + |
| 176 | + location @handle_redirect_marketing { |
| 177 | + # resolver 8.8.8.8; |
| 178 | + set $saved_redirect_location '$upstream_http_location'; |
| 179 | + set $path $saved_redirect_location; |
| 180 | + |
| 181 | + if ($saved_redirect_location ~* ^https://kbs.comradeserver.com/(.*)$) { |
| 182 | + set $path $1; |
| 183 | + } |
| 184 | + |
| 185 | + proxy_http_version 1.1; |
| 186 | + proxy_set_header Connection ""; |
| 187 | + client_max_body_size 300M; |
| 188 | + proxy_set_header Host kbs.comradeserver.com; |
| 189 | + # proxy_pass $saved_redirect_location; |
| 190 | + proxy_pass https://marketing/$path; |
| 191 | + proxy_intercept_errors on; |
| 192 | + recursive_error_pages on; |
| 193 | + error_page 301 302 307 = @handle_redirect_marketing; |
| 194 | + } |
| 195 | + |
| 196 | + # location /_track_/ { |
| 197 | + # index index.html; |
| 198 | + # ssi_silent_errors off; |
| 199 | + # allow all; |
| 200 | + # # this ensures that a downstream cache service will revalidate. |
| 201 | + # add_header Cache-Control 'no-cache'; |
| 202 | + |
| 203 | + # # rewrite .* / redirect; |
| 204 | + # rewrite .* /; |
| 205 | + |
| 206 | + # root /kb/deployment/services/kbase-ui/dist; |
| 207 | + # } |
| 208 | + } |
| 209 | +} |
0 commit comments