forked from vbguyny/ws4kp
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathnginx.conf
More file actions
60 lines (49 loc) · 1.72 KB
/
Copy pathnginx.conf
File metadata and controls
60 lines (49 loc) · 1.72 KB
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
http {
server {
root /usr/share/nginx/html;
merge_slashes off;
listen 80 default_server;
listen [::]:80 default_server;
proxy_set_header Connection '';
proxy_http_version 1.1;
chunked_transfer_encoding off;
proxy_buffering off;
proxy_cache off;
server_name _;
location ~ ^/cors/? {
resolver 127.0.0.11 valid=15s;
# We use $request_uri (the raw, untouched URL)
# and grab EVERYTHING after 'u=' until the end of the string ($)
set $greedy_url "";
if ($request_uri ~* "[?&]u=(.*)$") {
set $greedy_url $1;
}
if ($greedy_url = "") {
return 400 "Missing target URL in 'u' parameter";
}
# Do NOT pass $host; pass the proxy's host so the weather service
# doesn't see "localhost" and reject the request.
# [also] Forward your browser's identity
# This "fools" Mesonet into thinking a real person is visiting
proxy_set_header User-Agent $http_user_agent;
proxy_set_header X-Requested-With "XMLHttpRequest";
proxy_set_header Host $proxy_host;
proxy_set_header X-Requested-With "XMLHttpRequest";
add_header X-Debug-Proxy-URL $greedy_url;
# We pass the greedy URL exactly as it was captured.
set $backend_url "http://ws4kp-cors-anywhere/$greedy_url";
proxy_pass $backend_url;
}
location / {
add_header "Access-Control-Allow-Origin" "*";
include /etc/nginx/mime.types;
root /usr/share/nginx/html;
# alias /usr/share/nginx/html;
autoindex on;
# index index.html;
add_header 'X-debug-message' "$uri";
try_files $uri $uri/ /index.html =404;
}
}
}
events { }