Browse code
(init)
fiddlerwoaroof authored on 17/01/2020 02:24:45
Showing 5 changed files
Showing 5 changed files
1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,36 @@ |
1 |
+To setup: |
|
2 |
+ |
|
3 |
+- copy the reload-nginx shell script somewhere sane: |
|
4 |
+ |
|
5 |
+ ```bash |
|
6 |
+ mkdir -p /root/bin |
|
7 |
+ sudo cp reload-nginx /root/bin |
|
8 |
+ ``` |
|
9 |
+ |
|
10 |
+- copy nginx-reloader.path (change this to point to the path where the nginx configuration files are) and |
|
11 |
+ nginx-reloader.service (change this to point to the reload-nginx shell script) to /etc/systemd/system (or an |
|
12 |
+ equivalent directory see `man systemd.unit`) |
|
13 |
+ |
|
14 |
+ ```bash |
|
15 |
+ vim nginx-reloader.path |
|
16 |
+ vim nginx-reloader.service |
|
17 |
+ sudo cp nginx-reloader.{path,service} /etc/systemd/system |
|
18 |
+ ``` |
|
19 |
+ |
|
20 |
+- enable the new systemd units: |
|
21 |
+ |
|
22 |
+ ```bash |
|
23 |
+ sudo systemctl enable nginx-reloader.{path,service} |
|
24 |
+ sudo systemctl start nginx-reloader.{path,service} |
|
25 |
+ ``` |
|
26 |
+ |
|
27 |
+- adjust the add-reverse-proxy script to use the path in nginx-reloader.path and run the add-reverse-proxy |
|
28 |
+ script |
|
29 |
+ ```bash |
|
30 |
+ vim add-reverse-proxy |
|
31 |
+ ./add-reverse-proxy http://localhost:9203 foo.bar.baz www.foo.bar.baz |
|
32 |
+ ``` |
|
33 |
+ |
|
34 |
+- ??? |
|
35 |
+ |
|
36 |
+- profit. |
0 | 37 |
new file mode 100755 |
... | ... |
@@ -0,0 +1,21 @@ |
1 |
+#!/usr/bin/env bash |
|
2 |
+ |
|
3 |
+get-reverse-proxy() { |
|
4 |
+local target=$1 |
|
5 |
+shift |
|
6 |
+cat <<EOF |
|
7 |
+server { |
|
8 |
+ listen 80; |
|
9 |
+ server_name $@; |
|
10 |
+ location / { |
|
11 |
+ proxy_pass $target; |
|
12 |
+ proxy_set_header Host \$host; |
|
13 |
+ proxy_set_header X-Real-IP \$remote_addr; |
|
14 |
+ proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for; |
|
15 |
+ proxy_set_header X-Forwarded-Proto \$scheme; |
|
16 |
+ } |
|
17 |
+} |
|
18 |
+EOF |
|
19 |
+} |
|
20 |
+ |
|
21 |
+get-reverse-proxy "$@" > "$HOME"/sites/"$2".conf |