使用Gitea搭建Git服务器

gitea官网html

gitea官网安装文档git

gitea官方下载地址web

安装过程参考:apache

使用Gitea搭建Git服务器:https://blog.gmem.cc/gitea-server-install-logubuntu

使用Gitea自建私有git服务器:https://hezuiwan.com/archives/207服务器

ubuntu/deepin推荐安装在/opt/gitea/目录下,并建立专用的git帐户来管理,参考Linux环境下如何搭建Git服务器(Git Server)网站

注意:若是是在服务器上部署,要记得开启gitea服务端口的访问权限(默认是3000),待全部配置结束后能够关闭ui

安装好后访问需经过3000端口,即gitea.service.com:3000而非gitea.service.com才可访问到,考虑到还要加上ssl加密,能够经过apache的代理功能来去除网址中的端口号加密

1.修改apache的配置文件apache2.conf,加载apache的代理相关模块代理

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
LoadModule proxy_http_module modules/mod_proxy_http.so

apache的代理模块有上述几种,这里只须要加下列两种就能够

# Include module configuration:
IncludeOptional mods-enabled/*.load
IncludeOptional mods-enabled/*.conf

LoadModule proxy_module /usr/lib/apache2/modules/mod_proxy.so
LoadModule proxy_http_module /usr/lib/apache2/modules/mod_proxy_http.so

2.写网站代理配置

http转https配置

<VirtualHost *:80>
  ServerAdmin webmaster@gitea.service.com
  DocumentRoot /var/www/html/
  ServerName gitea.service.com

  RewriteEngine on
  RewriteCond %{SERVER_NAME} =gitea.service.com
  RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

 443端口转3000端口配置,这里使用Let's Encrypt服务使网址得以加密

<IfModule mod_ssl.c>
<VirtualHost *:443>
  ServerName gitea.service.com
  ProxyPreserveHost On #当启用时,此选项将把传入请求的"Host:"行传递给被代理的主机,而不是传递在ProxyPass中指定的主机名。
  ProxyRequests Off #反向代理为Off

  <Proxy *>
    Order deny,allow
    Allow from all
  </Proxy>

  ProxyPass / http://127.0.0.1:3000/
  ProxyPassReverse / http://127.0.0.1:3000/

  SSLCertificateFile /etc/letsencrypt/live/gitea.service.com/fullchain.pem
  SSLCertificateKeyFile /etc/letsencrypt/live/gitea.service.com/privkey.pem
  Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>

最后,别忘了关闭3000端口的访问权限

相关文章
相关标签/搜索