Просмотр исходного кода

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

cia-freehand
toj 4 лет назад
Родитель
Сommit
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
 
2
 
3
 services:
3
 services:
4
     nginx:
4
     nginx:
5
-	container_name: "nginx-proxy"
5
+        container_name: "nginx-proxy"
6
         build:
6
         build:
7
             context: .
7
             context: .
8
             dockerfile: ./nginx/Dockerfile
8
             dockerfile: ./nginx/Dockerfile

+ 2
- 2
kill_production.sh Просмотреть файл

1
 #!/bin/sh
1
 #!/bin/sh
2
 
2
 
3
 ### Stops and removes the nginx proxy
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
 ### Stops and removes the nodejs app container
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
 
13
 
14
     server_name freehand.com www.freehand.com;
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
 ### SSL Stuff
18
 ### SSL Stuff
29
 server {
19
 server {
39
     index index.html index.htm index.php index.nginx-debian.html;
29
     index index.html index.htm index.php index.nginx-debian.html;
40
 
30
 
41
     location / {
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
     location ~/\.ht {
53
     location ~/\.ht {
63
 
63
 
64
     server_name craftinamerica.org www.craftinamerica.org;
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
 ### SSL Stuff
68
 ### SSL Stuff
83
 server {
69
 server {
84
     listen 443 ssl http2;
70
     listen 443 ssl http2;
93
     index index.html index.htm index.php index.nginx-debian.html;
79
     index index.html index.htm index.php index.nginx-debian.html;
94
 
80
 
95
     location / {
81
     location / {
82
+        #blocks blank user_agents
83
+        if ($http_user_agent = "") { return  301 $scheme://www.google.com/; }
84
+
96
         proxy_set_header        Host              $host;
85
         proxy_set_header        Host              $host;
97
         proxy_set_header        X-Real-IP         $remote_addr;
86
         proxy_set_header        X-Real-IP         $remote_addr;
98
         proxy_set_header        X-Forwarded-For   $proxy_add_x_forwarded_for;
87
         proxy_set_header        X-Forwarded-For   $proxy_add_x_forwarded_for;

+ 1
- 1
nginx/configs/nginx.conf Просмотреть файл

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

+ 1
- 1
rebuild_production.sh Просмотреть файл

1
 #!/bin/sh
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
 #!/bin/bash
1
 #!/bin/bash
2
 
2
 
3
-docker stop production_nginx_1
3
+docker stop nginx-proxy
4
 
4
 
5
 ### Get new keys
5
 ### Get new keys
6
 sudo certbot renew
6
 sudo certbot renew
7
 
7
 
8
 ### Remove the old keys
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
 ### Copy over the new keys
14
 ### Copy over the new keys
15
 sudo cat /etc/letsencrypt/live/craftinamerica.org/fullchain.pem > /opt/proxy/nginx/keys/letsencrypt.crt
15
 sudo cat /etc/letsencrypt/live/craftinamerica.org/fullchain.pem > /opt/proxy/nginx/keys/letsencrypt.crt
17
 sudo cat /etc/letsencrypt/live/freehand.com/fullchain.pem > /opt/proxy/nginx/keys/letsencrypt-freehand.crt
17
 sudo cat /etc/letsencrypt/live/freehand.com/fullchain.pem > /opt/proxy/nginx/keys/letsencrypt-freehand.crt
18
 sudo cat /etc/letsencrypt/live/freehand.com/privkey.pem > /opt/proxy/nginx/keys/letsencrypt-freehand.key
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"

Загрузка…
Отмена
Сохранить