-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathserver.conf
65 lines (58 loc) · 2.46 KB
/
server.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
# -------------------------------------------------------------------------------------------
# config ssl
1. update ip for domain
2. apply ssl and get pem and key file on domain server
3. upload files into server machine
# -------------------------------------------------------------------------------------------
# path: /etc/nginx/nginx.conf
events {}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
log_format postdata $request_body;
server {
#监听443端口
listen 443 ssl;
#你的域名
server_name translate.informal.top;
# access_log off;
#ssl证书的pem文件路径
ssl_certificate /etc/letsencrypt/live/translate.informal.top/translate.informal.top_cert_chain.pem;
#ssl证书的key文件路径
ssl_certificate_key /etc/letsencrypt/live/translate.informal.top/translate.informal.top_key.key;
location / {
# return 701;
# proxy_pass http://baidu.com;
# root /home/hzp18838965591;
# index index.html;
# return 200 $request_uri "abc";
access_log /home/PopTranslate/access_log postdata;
proxy_pass http://localhost:1996/translate;
}
}
server {
listen 80;
server_name translate.informal.top;
#将请求转成https
rewrite ^(.*)$ https://$host$1 permanent;
}
}
# -------------------------------------------------------------------------------------------
# restart shell
date >> /home/PopTranslate/crontab.log
pkill -9 -f main_run.py
nohup /usr/bin/python3.9 main_run.py >> /home/PopTranslate/crontab.log 2>&1 &
systemctl restart nginx >> /home/PopTranslate/crontab.log
date >> /home/PopTranslate/crontab.log
echo "\n\n\n" >> /home/PopTranslate/crontab.log
# -------------------------------------------------------------------------------------------
# crontab
0 0 * * * cd /home/PopTranslate && sh restart.sh
# -------------------------------------------------------------------------------------------
# test
curl -d '{"target":"zh", "source":"auto", "q":"dog"}' -H "Content-Type: application/json" -X POST https://translate.informal.top
curl -d '{"target":"zh", "source":"auto", "q":"dog"}' -H "Content-Type: application/json" -X POST http://localhost:5000/translate
# 20241224
curl -d '{"target":"en", "q":"i like dog so much"}' -H "Content-Type: application/json" -X POST http://110.238.111.87:1996/translate