-
Notifications
You must be signed in to change notification settings - Fork 12
/
ipcalf.conf
40 lines (37 loc) · 1.07 KB
/
ipcalf.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
# nginx configuration for <ipcalf.com>
# provides remote address in several content-negotated/query-requested formats
map $http_accept $ipcalf_header_type {
default "text";
"~text/html" "html";
"~application/json" "json";
}
map $arg_format $ipcalf_type {
default $arg_format;
'' $ipcalf_header_type;
}
server {
listen 80;
server_name .ipcalf.com;
location / {
default_type '';
if ($ipcalf_type = text) {
add_header Vary Accept;
add_header Cache-Control "private, no-cache";
add_header Content-Type text/plain;
return 200 "$remote_addr";
}
if ($ipcalf_type = json) {
add_header Vary Accept;
add_header Cache-Control "private, no-cache";
add_header Access-Control-Allow-Origin *;
add_header Content-Type application/json;
return 200 "\"$remote_addr\"";
}
#if ($ipcalf_type = html) {
add_header Vary Accept;
add_header Cache-Control "private, no-cache";
add_header Content-Type text/html;
return 200 "Your IP address is: <h1>$remote_addr</h1> Have a nice day.";
#}
}
}