Ticket #2033: nginx.conf

File nginx.conf, 1.8 KB (added by giovani.rinaldi.azion.com@…, 6 years ago)

Minimal nginx.conf

Line 
1user nginx;
2worker_processes 1;
3error_log /usr/local/nginx/logs/error.log debug;
4daemon off;
5master_process off;
6
7events {
8 worker_connections 1024;
9}
10
11http {
12 include mime.types;
13 default_type application/octet-stream;
14
15 log_format main '$remote_addr - $remote_user [$time_local] "$request" '
16 '$status $body_bytes_sent "$http_referer" '
17 '"$http_user_agent" "$http_x_forwarded_for"';
18
19 error_log /usr/local/nginx/logs/error.log debug;
20 access_log /usr/local/nginx/logs/access.log main;
21
22 sendfile on;
23 keepalive_timeout 65;
24
25 resolver 127.0.0.1:53 ipv6=off;
26
27 # origin server
28 server {
29 listen 8081;
30 server_name origin.com;
31 root html;
32 index index.html;
33 }
34
35 # redirect server
36 server {
37 listen 8080;
38 server_name redirect.com;
39 location / {
40 return 302 http://origin.com:8081$request_uri;
41 }
42 }
43
44 # upstream for proxy server to access "redirect server" upstream with keepalive
45 upstream redirect_server {
46 server 127.0.0.1:8080;
47 keepalive 4;
48 }
49 # proxy server
50 server {
51 listen 80;
52 server_name example.com;
53
54 proxy_intercept_errors on;
55 error_page 302 =200 @handle_redirect;
56
57 location @handle_redirect {
58 proxy_http_version 1.1;
59 proxy_set_header Connection "";
60
61 # proxy_pass withou upstream or keepalive
62 set $redirect_location '$upstream_http_location';
63 proxy_pass $redirect_location;
64 }
65
66 location / {
67 proxy_http_version 1.1;
68 proxy_set_header Connection "";
69
70 # use upstream and keepalive
71 proxy_pass http://redirect_server;
72 }
73 }
74}