how-to-use/web.txt

47 lines
1.7 KiB
Plaintext

1.如何设置nginx代理,包括https。
示例位置:/etc/nginx/nginx.conf
nginx 在 http 下设置如下内容
server {
listen 443 ssl;
server_name ww.sinxmiao.cn;
client_max_body_size 500m; 这里不设置,大一点的仓库不能push
ssl_certificate/root/ssl/sinxmiao.crt;
ssl_certificate_key /root/ssl/sinxmiao.key;
location / {
proxy_pass http://localhost:3000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header x-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
nginx http 强制重定向到https
新建一个server (Server 在 http {} 里面):
server {
listen 80;
server_namewww.sinxmiao.cn;
rewrite ^(.*)$ https://$host$1 permanent;
}
2.网页中插入一个备案号示例:
示例位置:/var/lib/gitea/custom/templates/custom/extra_links.tmpl
<a class="item" href="https://beian.miit.gov.cn/">豫ICP备2021023625号-1</a>
3.记一次cppreference nginx设置
cppreference目录结构如下:
root -->
common/xxx.js
zh/index.html
server {
listen 80;
server_name 192.168.137.66;
location / {
root /home/ypi/document/cppreference/reference/zh;
index index.html;
try_files $uri $uri/ =404;
}
这里的 /common/如果不知道填什么,可以浏览器查看 server_name 后面直接跟的路径。
location /common/ {
root /home/ypi/document/cppreference/reference/;
}
}