-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnginx-camel.conf
151 lines (128 loc) · 5.18 KB
/
nginx-camel.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
server {
listen 443 ssl;
server_name camel.elliotliu.com;
ssl_certificate /etc/letsencrypt/live/camel.elliotliu.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/camel.elliotliu.com/privkey.pem;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers on;
location = /about {
root /var/www/html;
try_files /about.html =404;
}
location /search/ws {
proxy_pass http://localhost:8765;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
location /playground/ws {
proxy_pass http://localhost:3000/playground/ws;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
location = /playground {
root /var/www/html;
try_files /playground.html =404;
}
location /run-code {
proxy_pass http://localhost:3000/run-code;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
location /get-questions {
proxy_pass http://localhost:3000/get-questions;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
location = / {
# Proxy to the Real World OCaml website
proxy_pass https://dev.realworldocaml.org/;
sub_filter_once on;
# Inject JavaScript before <body> for the OCaml editor
sub_filter '<head>' '
<head>
<link rel="stylesheet" href="/myjs/splash.css">
<link rel="stylesheet" href="/myjs/toggle-toc.css">
<link rel="stylesheet" href="/myjs/searchbar.css">
';
sub_filter '<body>' '
<body>
<script type="module" src="/myjs/search-bar.js"></script>
<!-- Custom Splash Page Overlay -->
<div id="splash-page">
<h1>Welcome to CamelTutor</h1>
<p>Real World Ocaml, made interactive</p>
<!-- Links Section -->
<div id="splash-links">
<a href="/playground">Playground</a>
<a href="/about">About</a>
<a href="/settings">Settings</a>
</div>
<!-- Scroll Arrow -->
<div id="scroll-arrow">↓</div>
<!-- Camel Image -->
<img src="/myjs/camel.jpg" alt="Camel image" id="camel-image">
</div>
<!-- Custom JavaScript for Splash Page Scroll -->
<script src="/myjs/splash.js"></script>
<script src="/myjs/toggle-toc.js"></script>
';
# Set headers for proxying
proxy_set_header Accept-Encoding "";
proxy_set_header Host dev.realworldocaml.org;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_hide_header Content-Security-Policy;
}
location / {
# Proxy to the Real World OCaml website
proxy_pass https://dev.realworldocaml.org/;
sub_filter '<script src="js/prism.js">' '';
sub_filter '<script src="js/min/modernizr-min.js">' '';
# Inject JavaScript before <head> for the OCaml editor
sub_filter_once on;
sub_filter '<head>' '
<head>
<link rel="stylesheet" href="/myjs/editor.css">
<link rel="stylesheet" href="/myjs/quiz.css">
<link rel="stylesheet" href="/myjs/searchbar.css">
<!-- Load Monaco Editor -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.31.1/min/vs/loader.min.js"></script>
<script type="module" src="/myjs/init-editor.js"></script>
<script type="module" src="/myjs/search-bar.js"></script>
<script type="module" src="/myjs/scroll-helper.js"></script>
';
# Set headers for proxying
proxy_set_header Accept-Encoding "";
proxy_set_header Host dev.realworldocaml.org;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_hide_header Content-Security-Policy;
}
# Serve local JavaScript file for editor injection
location /myjs/ {
alias /var/www/html/js/;
autoindex on;
}
}
# Redirect HTTP to HTTPS
server {
listen 80;
server_name camel.elliotliu.com;
return 301 https://$host$request_uri;
}