服务器配置https记录

1
2
3
4
5
cd /
find -name "www.xxx.crt"
# 寻找我原来证书的位置 => 我忘记 原来证书放哪里了,
# 找到证书位置后  /www/server/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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
user  www www;
worker_processes auto;
error_log  /www/wwwlogs/nginx_error.log  crit;
pid        /www/server/nginx/logs/nginx.pid;
worker_rlimit_nofile 51200;

events
    {
        use epoll;
        worker_connections 51200;
        multi_accept on;
    }

http
    {
        include       mime.types;
		#include luawaf.conf;

		include proxy.conf;

        default_type  application/octet-stream;

        server_names_hash_bucket_size 512;
        client_header_buffer_size 32k;
        large_client_header_buffers 4 32k;
        client_max_body_size 50m;

        sendfile   on;
        tcp_nopush on;

        keepalive_timeout 82;

        tcp_nodelay on;

        fastcgi_connect_timeout 300;
        fastcgi_send_timeout 300;
        fastcgi_read_timeout 300;
        fastcgi_buffer_size 64k;
        fastcgi_buffers 4 64k;
        fastcgi_busy_buffers_size 128k;
        fastcgi_temp_file_write_size 256k;
		fastcgi_intercept_errors on;

        gzip on;
        gzip_min_length 1k;
        gzip_buffers     4 16k;
        gzip_http_version 1.1;
        gzip_comp_level 2;
        gzip_types     text/plain application/javascript application/x-javascript text/javascript text/css application/xml;
        gzip_vary on;
        gzip_proxied   expired no-cache no-store private auth;
        gzip_disable   "MSIE [1-6]\.";

        limit_conn_zone $binary_remote_addr zone=perip:10m;
		limit_conn_zone $server_name zone=perserver:10m;

        server_tokens off;
        access_log off;
        
  server
    {
        listen 80;
        server_name admin.lyr-2000.xyz;
        tcp_nodelay  on;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header REMOTE-HOST $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
 
        
 
        location / {
          
        
    	    # rewrite ^/(.*)$ /$1 break;
          proxy_pass   http://localhost:8081/;
          proxy_cookie_path ~*^/.* /;
        }
 
        location ~ /\.
        {
            deny all;
        }

        access_log  /www/wwwlogs/access.log;
    }      
    
    
    server
    {
        listen 80;
        server_name blog.lyr-2000.xyz;
        tcp_nodelay  on;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header REMOTE-HOST $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
 
        
 
        # location /ffff {
          
        
    	   # # rewrite ^/(.*)$ /$1 break;
        #   proxy_pass   http://localhost:8083/;
        #   proxy_cookie_path ~*^/.* /;
        # }
        
        
        location /css {
          root /www/static/;
    			if (!-f $request_filename) { #请求的文件不存在,就反向代理
    				proxy_pass http://127.0.0.1:8083;
    				 
 
    				break;
    			}
        
        }
        
        location ~ ^/favicon\.ico$ {

           root    /www/static/;

        }
        
        location /js {
          root /www/static/;
    			if (!-f $request_filename) { #请求的文件不存在,就反向代理
    				proxy_pass http://127.0.0.1:8083;
    			  
    				break;
    			}
        
        }
         location /fonts {
          root /www/static/;
    			if (!-f $request_filename) { #请求的文件不存在,就反向代理
    				proxy_pass http://127.0.0.1:8083;
    				break;
    			}
        
        }
         location /img {
          root /www/static/;
    			if (!-f $request_filename) { #请求的文件不存在,就反向代理
    				proxy_pass http://127.0.0.1:8083;
    				break;
    			}
        
        }
         location /lib {
          root /www/static/;
    			if (!-f $request_filename) { #请求的文件不存在,就反向代理
    				proxy_pass http://127.0.0.1:8083;
    				break;
    			}
        
        }
        location /extra_tool {
           root /www/static/;
    		 	 if (!-f $request_filename) { #请求的文件不存在,就反向代理
    				proxy_pass http://127.0.0.1:8083;
    				break;
    			}
        }
        
       
         
        location / {
          error_page  500 502 503 504  https://www.abc.com/lib/500.html;
        
    	    rewrite ^/(.*)$ /$1 break;
          proxy_pass   http://1.15.108.110:8083/;
        }
        
        
 
        location ~ /\.
        {
            deny all;
        }

        access_log  /www/wwwlogs/access.log;
    }         

server
    {
        listen 80;
        server_name www.abc.com;
    
     
       tcp_nodelay  on;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header REMOTE-HOST $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
 
        
      rewrite ^(.*)$ https://${server_name}$1 permanent;  
      
      location ~ .*\.(js|css)$ {
         proxy_pass http://127.0.0.1:8080;
     }
        
        
        
      

 
        location ~ /\.
        {
            deny all;
        }

        access_log  /www/wwwlogs/access.log;
    }
    server {
      listen 80;
      server_name novel_backend.lyr-2000.xyz;
      location / {
          
          proxy_pass   http://localhost:8041/;
      }
    
    }
    server
    {
        listen 80;
        server_name m.lyr-2000.xyz;
        # index index.html index.htm index.php;
        # root  /www/server/phpmyadmin;

        #error_page   404   /404.html;
        # include enable-php.conf;
     
      
        
        location / {
          
        
    	    rewrite ^/(.*)$ /$1 break;
          proxy_pass   http://1.15.108.110:8089/;
        }

        location ~ /\.
        {
            deny all;
        }

        access_log  /www/wwwlogs/access.log;
    }
    server
    {
        listen 80;
        server_name cloud.lyr-2000.xyz;
        location / {
    	    rewrite ^/(.*)$ /$1 break;
          proxy_pass   http://1.15.108.110:5212/;
        }
        location ~ /\.
        {
            deny all;
        }
        access_log  /www/wwwlogs/access_nextcloud.log;
    }
    
    
    
    server
    {
        listen 80;
        server_name coderead.lyr-2000.xyz;
        tcp_nodelay  on;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header REMOTE-HOST $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
 
        
 
        location / {
          
        
    	    # rewrite ^/(.*)$ /$1 break;
          proxy_pass   http://localhost:8686/;
          proxy_cookie_path ~*^/.* /;
        }
 
        location ~ /\.
        {
            deny all;
        }

        access_log  /www/wwwlogs/access.log;
    }    
    
     server
    {
        listen 80;
        server_name cet.lyr-2000.xyz;
        tcp_nodelay  on;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header REMOTE-HOST $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
 
        
 
        location / {
          
        
    	    # rewrite ^/(.*)$ /$1 break;
          proxy_pass   http://localhost:8088/;
          proxy_cookie_path ~*^/.* /;
        }
 
        location ~ /\.
        {
            deny all;
        }

        access_log  /www/wwwlogs/access.log;
    }    
    
     
     
     
     
     
     server {
       listen       443 ssl http2;
       server_name  www.abc.com;
       
       ssl_certificate      1_www.abc.com_bundle.crt;
       ssl_certificate_key  2_www.abc.com.key;

       ssl_session_cache    shared:SSL:1m;
       ssl_session_timeout 5m;
       ssl_protocols TLSv1 TLSv1.1 TLSv1.2; #按照这个协议配置
       ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;#按照这个套件配置
       ssl_prefer_server_ciphers  on;
       
       
       
        proxy_set_header   Host $host;
        proxy_hide_header Server;
        proxy_set_header X-Real-IP      $remote_addr;
        proxy_set_header X-Forwarded-For $remote_addr;
 
       
       
       
     #if ($http_user_agent ~* (mobile|nokia|iphone|ipad|android|samsung|htc|blackberry)) {
      #  return 302    'http://m.lyr-2000.xyz' ;
      #}


        location /css {
          root /www/static/;
    			if (!-f $request_filename) { #请求的文件不存在,就反向代理
    				proxy_pass http://127.0.0.1:8080;
    				 
 
    				break;
    			}
        
        }
        
        location ~ ^/favicon\.ico$ {

           root    /www/static/;

        }
        
        location /js {
          root /www/static/;
    			if (!-f $request_filename) { #请求的文件不存在,就反向代理
    				proxy_pass http://127.0.0.1:8080;
    			  
    				break;
    			}
        
        }
         location /fonts {
          root /www/static/;
    			if (!-f $request_filename) { #请求的文件不存在,就反向代理
    				proxy_pass http://127.0.0.1:8080;
    				break;
    			}
        
        }
         location /img {
          root /www/static/;
    			if (!-f $request_filename) { #请求的文件不存在,就反向代理
    				proxy_pass http://127.0.0.1:8080;
    				break;
    			}
        
        }
         location /lib {
          root /www/static/;
    			if (!-f $request_filename) { #请求的文件不存在,就反向代理
    				proxy_pass http://127.0.0.1:8080;
    				break;
    			}
        
        }
        location /extra_tool {
           root /www/static/;
    		 	 if (!-f $request_filename) { #请求的文件不存在,就反向代理
    				proxy_pass http://127.0.0.1:8080;
    				break;
    			}
        }
        
       
         
        location / {
          error_page  500 502 503 504  https://www.abc.com/lib/500.html;
        
    	    rewrite ^/(.*)$ /$1 break;
          proxy_pass   http://1.15.108.110:8080/;
        }
        
      
    }
     
     
     
     
     
     
     

    
include /www/server/panel/vhost/nginx/*.conf;
}

把证书直接丢到

/www/server/nginx/conf 目录下面

https配置=>

 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
server {
       listen       443 ssl http2;
       server_name  admin.lyr-2000.xyz;
       ssl_certificate      admin.lyr-2000.xyz.crt;
       ssl_certificate_key  admin.lyr-2000.xyz.key;
       ssl_session_cache    shared:SSL:1m;
       ssl_session_timeout 5m;
       ssl_protocols TLSv1 TLSv1.1 TLSv1.2; #按照这个协议配置
       ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;#按照这个套件配置
       ssl_prefer_server_ciphers  on;
        proxy_set_header   Host $host;
        proxy_hide_header Server;
        proxy_set_header X-Real-IP      $remote_addr;
        proxy_set_header X-Forwarded-For $remote_addr;
     #if ($http_user_agent ~* (mobile|nokia|iphone|ipad|android|samsung|htc|blackberry)) {
      #  return 302    'http://m.lyr-2000.xyz' ;
      #}
        location / {
          error_page  500 502 503 504  https://www.lyr-2000.xyz/lib/500.html;
        
          rewrite ^/(.*)$ /$1 break;
          proxy_pass   http://1.15.108.110:8081/;
        }
}
     

用 springboot的话 也可以,但是 好像没办法 同一台服务器 跑多个 https 可能会端口占用,最好 还是 配到 nginx,然后让 nginx做域名转发