瀏覽代碼

:recycle: cleaned-up some scripts | adjusted nginx configs

cia-freehand
toj 4 年之前
父節點
當前提交
ce28e418f0
共有 6 個文件被更改,包括 34 次插入45 次删除
  1. 1
    1
      docker-compose.yml
  2. 2
    2
      kill_production.sh
  3. 24
    35
      nginx/configs/default.conf
  4. 1
    1
      nginx/configs/nginx.conf
  5. 1
    1
      rebuild_production.sh
  6. 5
    5
      renew_keys.sh

+ 1
- 1
docker-compose.yml 查看文件

@@ -2,7 +2,7 @@ version: '3'
2 2
 
3 3
 services:
4 4
     nginx:
5
-	container_name: "nginx-proxy"
5
+        container_name: "nginx-proxy"
6 6
         build:
7 7
             context: .
8 8
             dockerfile: ./nginx/Dockerfile

+ 2
- 2
kill_production.sh 查看文件

@@ -1,7 +1,7 @@
1 1
 #!/bin/sh
2 2
 
3 3
 ### Stops and removes the nginx proxy
4
-docker stop production_nginx_1 && docker rm production_nginx_1
4
+docker stop nginx-proxy && docker rm nginx-proxy
5 5
 
6 6
 ### Stops and removes the nodejs app container
7
-# docker stop production_nodejs_1 && docker rm production_nodejs_1
7
+# docker stop production_nodejs_1 && docker rm production_nodejs_1

+ 24
- 35
nginx/configs/default.conf 查看文件

@@ -13,17 +13,7 @@ server {
13 13
 
14 14
     server_name freehand.com www.freehand.com;
15 15
     
16
-    index index.html index.html index.php;
17
-
18
-    location / {
19
-        proxy_set_header    Host                 $host;
20
-        proxy_set_header    X-Real-IP            $remote_addr;
21
-        proxy_set_header    X-Forwarded-For      $proxy_add_x_forwarded_for;
22
-        proxy_set_header    X-Forwarded-Proto    $scheme;
23
-
24
-        proxy_pass         http://freehand;
25
-        proxy_redirect     off;
26
-    }
16
+    return 301 https://$host$request_uri;
27 17
 }
28 18
 ### SSL Stuff
29 19
 server {
@@ -39,15 +29,25 @@ server {
39 29
     index index.html index.htm index.php index.nginx-debian.html;
40 30
 
41 31
     location / {
42
-        proxy_set_header        Host              $host;
43
-        proxy_set_header        X-Real-IP         $remote_addr;
44
-        proxy_set_header        X-Forwarded-For   $proxy_add_x_forwarded_for;
45
-        proxy_set_header        X-Forwarded-Proto $scheme;
46
-        proxy_set_header        Accept-Encoding   "";
47
-        proxy_set_header        Proxy             "";
48
-
49
-        proxy_pass          http://freehand;
50
-        proxy_redirect      off;
32
+	#blocks blank user_agents
33
+        if ($http_user_agent = "") { return  301 $scheme://www.google.com/; }
34
+
35
+        proxy_set_header        Host                $host;
36
+        proxy_set_header        X-Forwarded-Host    $host;
37
+        proxy_set_header        X-Forwarded-Server  $host;
38
+        proxy_set_header        X-Forwarded-Proto   $scheme;
39
+        proxy_set_header        X-Real-IP           $remote_addr;
40
+        proxy_set_header        X-Forwarded-For     $proxy_add_x_forwarded_for;
41
+        proxy_set_header        Accept-Encoding     "";
42
+        proxy_set_header        Proxy               "";
43
+
44
+        proxy_pass_request_headers   on;
45
+        proxy_pass                   http://freehand;
46
+        proxy_redirect               off;
47
+
48
+        proxy_connect_timeout   300;
49
+        proxy_send_timeout      300;
50
+        proxy_read_timeout      300;
51 51
     }
52 52
 
53 53
     location ~/\.ht {
@@ -63,22 +63,8 @@ server {
63 63
 
64 64
     server_name craftinamerica.org www.craftinamerica.org;
65 65
     
66
-    # return 302 https://$host$request_uri;
67
-    
68
-    # WP
69
-    index index.html index.htm index.php index.nginx-debian.html;
70
-
71
-    location / {
72
-        proxy_set_header    Host                 $host;
73
-        proxy_set_header    X-Real-IP            $remote_addr;
74
-        proxy_set_header    X-Forwarded-For      $proxy_add_x_forwarded_for;
75
-        proxy_set_header    X-Forwarded-Proto    $scheme;
76
-
77
-        proxy_pass          http://craft;
78
-        proxy_redirect      off;
79
-    }
66
+    return 301 https://$host$request_uri;
80 67
 }
81
-
82 68
 ### SSL Stuff
83 69
 server {
84 70
     listen 443 ssl http2;
@@ -93,6 +79,9 @@ server {
93 79
     index index.html index.htm index.php index.nginx-debian.html;
94 80
 
95 81
     location / {
82
+        #blocks blank user_agents
83
+        if ($http_user_agent = "") { return  301 $scheme://www.google.com/; }
84
+
96 85
         proxy_set_header        Host              $host;
97 86
         proxy_set_header        X-Real-IP         $remote_addr;
98 87
         proxy_set_header        X-Forwarded-For   $proxy_add_x_forwarded_for;

+ 1
- 1
nginx/configs/nginx.conf 查看文件

@@ -14,7 +14,7 @@ http {
14 14
     include       /etc/nginx/mime.types;
15 15
     default_type  application/octet-stream;
16 16
     
17
-    client_max_body_size 8M;
17
+    client_max_body_size 16M;
18 18
 
19 19
     log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
20 20
                       '$status $body_bytes_sent "$http_referer" '

+ 1
- 1
rebuild_production.sh 查看文件

@@ -1,2 +1,2 @@
1 1
 #!/bin/sh
2
-docker-compose build --no-cache && docker-compose up
2
+docker-compose build --no-cache && docker-compose up -d

+ 5
- 5
renew_keys.sh 查看文件

@@ -1,15 +1,15 @@
1 1
 #!/bin/bash
2 2
 
3
-docker stop production_nginx_1
3
+docker stop nginx-proxy
4 4
 
5 5
 ### Get new keys
6 6
 sudo certbot renew
7 7
 
8 8
 ### Remove the old keys
9
-rm /proxy/nginx/keys/letsencrypt/old/letsencrypt*
9
+rm /proxy/nginx/keys/old/letsencrypt*
10 10
 
11
-### Deprecate and back up the current keys
12
-mv /opt/proxy/nginx/keys/letsencrypt* /opt/proxy/nginx/keys/old
11
+### Deprecate and back-up the current keys
12
+mv /opt/proxy/nginx/keys/letsencrypt* /opt/proxy/nginx/keys/old/
13 13
 
14 14
 ### Copy over the new keys
15 15
 sudo cat /etc/letsencrypt/live/craftinamerica.org/fullchain.pem > /opt/proxy/nginx/keys/letsencrypt.crt
@@ -17,4 +17,4 @@ sudo cat /etc/letsencrypt/live/craftinamerica.org/privkey.pem > /opt/proxy/nginx
17 17
 sudo cat /etc/letsencrypt/live/freehand.com/fullchain.pem > /opt/proxy/nginx/keys/letsencrypt-freehand.crt
18 18
 sudo cat /etc/letsencrypt/live/freehand.com/privkey.pem > /opt/proxy/nginx/keys/letsencrypt-freehand.key
19 19
 
20
-echo "RUN the ./rebuild.sh script now to move over the newly generated keys and restart the container"
20
+echo "RUN the ./rebuild_production.sh script now to move over the newly generated keys and restart the container"

Loading…
取消
儲存