-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathnginx.conf
181 lines (149 loc) · 6.4 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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
## Nginx config file for RStudio/Shiny/VSCode/Jupyter Servers /etc/nginx/sites-available/default
##
## Change occurrences of "example.com" as appropriate
##
## Port numbers are the standard defaults of each software as of FEB-21
##
## If your version doesn't work, check first that backslashes and punctuations are correct
##
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
root /var/www/html;
index index.php index.html index.htm index.nginx-debian.html;
server_name example.com www.example.com;
# Redirection from root. Afterwards, attempt to serve request as file, then as directory, then fall back to displaying a 404.
location / {
rewrite ^/$ https://newexample.com/$1 redirect;
try_files $uri $uri/ =404;
}
# RStudio Server Open Source
location /rstudio/ {
proxy_pass http://127.0.0.1:8787/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
}
# Shiny Server Open Source
location /shiny/ {
proxy_pass http://127.0.0.1:3838/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
rewrite ^(/shiny/[^/]+)$ $1/ permanent;
}
# Jupyter Lab (Open Source) DO NOT ADD
location /jupyter/ {
# you need to set the followings in the jupyterlab conf file:
# c.Spawner.default_url = '/lab'
# c.JupyterHub.base_url = '/jupyter'
# c.JupyterHub.bind_url = 'http://:8000/jupyter'
proxy_pass http://127.0.0.1:8000;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header X-Scheme $scheme;
proxy_buffering off;
}
# code-server (VSCode Open Source)
location /vscode/ {
proxy_pass http://127.0.0.1:8080/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Accept-Encoding gzip;
}
# WiseMapping (XMind-like Open Source)
location /mindmap/ {
proxy_pass http://127.0.0.1:9258/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
}
# Shiny App by Docker
# docker container should be run as:
location /docker_app/ {
proxy_pass http://127.0.0.1:6755/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
}
# plumber APIs
location /apis/utils/ { proxy_pass http://127.0.0.1:6161/; }
location /apis/distances/ { proxy_pass http://127.0.0.1:6801/; }
location /apis/catchareas/ { proxy_pass http://127.0.0.1:6802/; }
location /apis/basemaps/ { proxy_pass http://127.0.0.1:6803/; }
# TileServer (osrm) running on aPache on port 8081
#location /tileserver/ {
# proxy_pass http://127.0.0.1:8081/;
# proxy_http_version 1.1;
# proxy_set_header Upgrade $http_upgrade;
# proxy_set_header Connection $connection_upgrade;
#}
# GeoRouter Back-Ends, partitioned by profiels: car, bike, foot
location /osrm/car/ { proxy_pass http://127.0.0.1:5001; }
location /osrm/bike/ { proxy_pass http://127.0.0.1:5002; }
location /osrm/foot/ { proxy_pass http://127.0.0.1:5003; }
# GeoRouter front-end (osrm)
#location /georouter/ {
# proxy_pass http://127.0.0.1:9966/;
# proxy_http_version 1.1;
# proxy_set_header Upgrade $http_upgrade;
# proxy_set_header Connection $connection_upgrade;
#}
# Nominatim (reverse) geocoding server
location /geoserver/ {
proxy_pass http://127.0.0.1:5009/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
}
# restrict access to mysql-dbninja to all IPs except specific IPs
# this directive can be repeated for as many locations as wanted
location /dbninja/ {
allow ip_address;
allow ip_address;
deny all;
}
# change <appname> with the subfolder/app you want to protect
# do not use $PUB_PATH as the path for the *public* shared folder, use instead its complete name
# remember to run "htpasswd -c $PUB_PATH/shiny_server/pwds/appname.pwds username" to create users/passwords
location /shiny/appname/ {
auth_basic "Username and Password are required";
auth_basic_user_file /usr/local/share/public/shiny_server/pwds/appname.pwds;
}
# PHP needed to run DBNinja as MySQL Web Client (version 7.4 as installed on Ubuntu 20.04.1)
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
}
# deny access to .htaccess files, if Apache's document root concurs with nginx's one
location ~ /\.ht {
deny all;
}
listen 443 ssl;
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
# managing requests to verify letsencrypt host
location ~ /.well-known {
allow all;
}
}
server {
if ($host = www.example.com) {
return 301 https://$host$request_uri;
}
if ($host = example.com) {
return 301 https://$host$request_uri;
}
server_name example.com www.example.com;
listen 80;
return 404;
}