[Unit]Description=GogsAfter=network.targetAfter=mysql.service mysqld.service[Service]# Modify these two values and uncomment them if you have# repos with lots of files and get an HTTP error 500 because# of that####LimitMEMLOCK=infinity#LimitNOFILE=65535Type=simpleUser=gitGroup=gitWorkingDirectory=/home/git/gogsExecStart=/home/git/gogs/gogs webRestart=alwaysRestartSec=2sEnvironment=USER=git HOME=/home/git# Some distributions may not support these hardening directives. If you cannot start the service due# to an unknown option, comment out the ones not supported by your version of systemd.ProtectSystem=fullPrivateDevices=yesPrivateTmp=yesNoNewPrivileges=true[Install]WantedBy=multi-user.target
### You should look at the following URL's in order to grasp a solid understanding# of Nginx configuration files in order to fully unleash the power of Nginx.# https://www.nginx.com/resources/wiki/start/# https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/# https://wiki.debian.org/Nginx/DirectoryStructure## In most cases, administrators will remove this file from sites-enabled/ and# leave it as reference inside of sites-available where it will continue to be# updated by the nginx packaging team.## This file will automatically load configuration files provided by other# applications, such as Drupal or Wordpress. These applications will be made# available underneath a path with that package name, such as /drupal8.## Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.##
server{listen80;# 你的域名或 IP 地址return301https://$host$request_uri;}
geo$gogs_signup_disabled_ip{default1;192.168.3.0/240;}
server{listen443ssl;# 115.154.175.254:5200server_name_;# 域名或 IP 地址ssl_certificate/home/git/cert/server/server.crt.pem;# 证书路径ssl_certificate_key/home/git/cert/server/server.key.pem;# 密钥路径ssl_protocolsTLSv1.2TLSv1.3;ssl_ciphers'AESGCM:CHACHA20:!aNULL:!MD5:!3DES';ssl_prefer_server_ciphersoff;error_page497301=307https://$host:5200$request_uri;location/register-denied.html{root/home/git/gogs/public/error_pages;}location=/gogs{rewrite^/(.*)https://$host:5200/gogs/break;}location^~/gogs/{set$flag0;if($gogs_signup_disabled_ip){set$flag"${flag}1";}if($uri~^/gogs/user/sign_up){set$flag"${flag}2";}if($flag="012"){rewrite^/(.*)https://$host:5200/register-denied.htmlbreak;}proxy_passhttps://localhost:5200/;# 代理到你的 HTTP 服务proxy_set_headerHost$host;proxy_set_headerX-Real-IP$remote_addr;proxy_set_headerX-Forwarded-For$proxy_add_x_forwarded_for;proxy_set_headerX-Forwarded-Proto$scheme;}location=/docsy{rewrite^/(.*)https://$host:5200/docsy/break;}location^~/docsy/{alias/home/git/hugo/xjrcBlog/public/;indexindex.html;}location^~/files{rewrite^/(.*)https://$host:5200/files/break;}location^~/files/{proxy_passhttp://localhost:5202/;proxy_set_headerHost$host;proxy_set_headerX-Real-IP$remote_addr;proxy_set_headerX-Forwarded-For$proxy_add_x_forwarded_for;proxy_set_headerX-Forwarded-Proto$scheme;}location/{alias/home/git/hugo/xjrcBlog/public/;indexindex.html;}}
[Unit]Description=GogsAfter=network.target[Service]Type=simpleUser=gitGroup=gitWorkingDirectory=/home/git/gogsExecStart=/home/git/gogs/gogs webRestart=alwaysRestartSec=2sEnvironment=USER=git HOME=/home/git# Some distributions may not support these hardening directives. If you cannot start the service due# to an unknown option, comment out the ones not supported by your version of systemd.ProtectSystem=fullPrivateDevices=yesPrivateTmp=yesNoNewPrivileges=true[Install]WantedBy=multi-user.target
serve-path:'.'# 修改为提供共享文件夹的地址bind:0.0.0.0# 全局监听port:5203# 一个不与其他服务冲突的端口path-prefix:/dufshidden:# 指定需要隐藏的文件,允许正则匹配-tmp-'*.log'-'*.lock'auth:# 指定访问控制,@前是'用户名:密码',@后是'文件夹:访问权限'组成的列表-admin:admin@/:rw-user:pass@/src:rw,/share-'@/'# According to the YAML spec, quoting is required.allow-all:false# allow-是全局设置,一旦设置为false,具体的访问控制将会被覆盖allow-upload:trueallow-delete:trueallow-search:trueallow-symlink:true# 允许指向根目录外的符号链接allow-archive:true# 允许压缩zip文件enable-cors:truerender-index:true# 当指定的目录不存在时,如果不存在./index.html页面,则显示404 not found ??——是否理解正确?render-try-index:true# 当指定的目录不存在时,如果不存在./index.html页面,则显示根目录列表 ??——是否理解正确?render-spa:trueassets:./assets/# 指定网页的样式文件(html,css,etc.)存储的文件夹log-format:'$remote_addr"$request"$status$http_user_agent'log-file:./dufs.logcompress:lowtls-cert:tests/data/cert.pem# tls(https)公钥tls-key:tests/data/key_pkcs1.pem# tls(https)私钥
#!/bin/sh## An example hook script for the "post-receive" event.## The "post-receive" script is run after receive-pack has accepted a pack# and the repository has been updated. It is passed arguments in through# stdin in the form# <oldrev> <newrev> <refname># For example:# aa453216d1b3e49e7f6f98441fa56946ddcd6a20 68f7abf4e6f922807889f52bc043ecd31b79f814 refs/heads/masterwhilereadoldrevnewrevrefname
dobranch=$(gitrev-parse--symbolic--abbrev-ref$refname)if["master"="$branch"];then# 同步更改到 /home/git/hugo/xjrcBlog/ 文件夹,并且强制与现在仓库样貌保持一致git--git-dir=/home/git/hugo/xjrcBlog/.git--work-tree=/home/git/hugo/xjrcBlogfetchorigin
git--git-dir=/home/git/hugo/xjrcBlog/.git--work-tree=/home/git/hugo/xjrcBlogreset--hardorigin/master
# 一个mermaid 图表生成脚本python3/home/git/scripts/git-mermaid.py\--repo-name=xjrc-blog\--repo-dir=.\--output-file=/home/git/hugo/xjrcBlog/content/zh-hans/tools/git-history/xjrc_blog/index.md
cd/home/git/hugo/xjrcBlog/
# 不尝试获取系统时间 不使用 Chmod 保护文件属性 --- 脚本不是以root用户运行的,没有对应权限/usr/local/bin/hugo--noChmod--noTimes
fidone