-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnginx.conf
112 lines (92 loc) · 2.98 KB
/
nginx.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# nginx.conf -- docker-openresty
#
# This file is installed to:
# `/usr/local/openresty/nginx/conf/nginx.conf`
# and is the file loaded by nginx at startup,
# unless the user specifies otherwise.
#
# It tracks the upstream OpenResty's `nginx.conf`, but removes the `server`
# section and adds this directive:
# `include /etc/nginx/conf.d/*.conf;`
#
# The `docker-openresty` file `nginx.vh.default.conf` is copied to
# `/etc/nginx/conf.d/default.conf`. It contains the `server section
# of the upstream `nginx.conf`.
#
# See https://github.com/openresty/docker-openresty/blob/master/README.md#nginx-config-files
#
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
worker_rlimit_nofile 7192;
env VIA_URL;
env H_EMBED_URL;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
set $template_location /templates;
location = /favicon.ico {
return 204;
access_log off;
log_not_found off;
}
location /id_/ {
set $upstream "";
rewrite_by_lua_file ./lua/get_pdf.lua;
resolver 8.8.8.8;
proxy_ssl_server_name on;
proxy_pass $upstream;
proxy_redirect ~^(.*)$ http://localhost:9081/id_/$1;
add_header Access-Control-Allow-Origin *;
# TODO:Strip any cookies set by the proxied server.
# See https://github.com/openresty/headers-more-nginx-module#annotations:Sh7NgtimEemYPZ-oriP0XQ
# Strip hypothesis cookies and authorization header.
set $stripped_cookie $http_cookie;
if ($http_cookie ~ "(.*)(?:^|;)\s*auth=[^;]+(.*)") {
set $new_cookie $1$2;
}
if ($http_cookie ~ "(.*)(?:^|;)\s*session=[^;]+(.*)") {
set $new_cookie $1$2;
}
proxy_set_header Cookie $stripped_cookie;
proxy_set_header Authorization "";
}
location /pdf/ {
internal;
root html;
default_type text/html;
content_by_lua_file ./lua/pdf_embed_hypothesis.lua;
add_header Content-Type text/html;
add_header Access-Control-Allow-Origin *;
}
location / {
access_by_lua_file ./lua/proxy_based_on_content_type.lua;
add_header Access-Control-Allow-Origin *;
}
location /templates {
internal;
alias html/templates/;
add_header Access-Control-Allow-Origin *;
}
location /static {
alias static/;
add_header Access-Control-Allow-Origin *;
}
}
}