Gogs: mudanças entre as edições
Criou página com 'http://blog.aeciopires.com/conhecendo-o-gogs/' |
Sem resumo de edição |
||
| Linha 1: | Linha 1: | ||
Wiki referente a instalação e configuração do gogs. | |||
## Gogs | |||
Com nginx | |||
* https://gogs.io/docs/intro/faqs | |||
* https://discuss.gogs.io/t/gogs-is-not-working-with-nginx-https-proxy/309/6 | |||
* https://gist.github.com/thiemok/f7ad440c2d358e531e4a3945603420cd | |||
* https://www.digitalocean.com/community/tutorials/how-to-set-up-gogs-on-ubuntu-14-04 | |||
Client / API | |||
* https://github.com/gogs/go-gogs-client/wiki | |||
## Instalação | |||
```bash | |||
apt install git mysql-server | |||
wget https://cdn.gogs.io/0.11.66/gogs_0.11.66_linux_amd64.tar.gz | |||
tar zxvf gogs_0.11.66_linux_amd64.tar.gz | |||
mv gogs /opt/ | |||
``` | |||
```bash | |||
wget -O /etc/init.d/gogs https://gist.githubusercontent.com/leo-bianchi/a9581a42e478130ad4612a185151d385/raw/7bcc42930ba457d0c1b5e5ff173ad5d6a3e6a721/gogs | |||
``` | |||
* Também pode ser encontrado [aqui](https://git.lfdb.com.br/lafabbrica/documentacao/raw/master/scripts_gogs/gogs) | |||
```bash | |||
sed -i '18s/etc/opt/g' /etc/init.d/gogs | |||
chmod +x /etc/init.d/gogs | |||
useradd -m -d /home/git -s /bin/false git | |||
chown git: /home/git | |||
chown -R git: /opt/gogs/ | |||
/etc/init.d/gogs restart | |||
update-rc.d -f gogs defaults | |||
``` | |||
## Criando base de dados | |||
```bash | |||
mysql -u root -p | |||
``` | |||
```sql | |||
GRANT ALL PRIVILEGES ON gogs.* TO 'gogs'@'localhost' identified by 'xu9AeMek'; | |||
``` | |||
```sql | |||
CREATE DATABASE gogs CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci; | |||
``` | |||
```sql | |||
flush privileges; | |||
``` | |||
## SSL | |||
* Para a implementação de SSL no nosso client gogs, utilizamos o [certbot](https://certbot.eff.org/). | |||
### Configuração SSL | |||
* Para a completa configuração do SSL no Gogs precisamos fazer alterações em dois arquivos de configuração: `app.ini` e o `arquivo de configuração do gogs no nginx`. | |||
* Configuração atual do arquivo de configuração: | |||
```nginx | |||
server { | |||
listen 80; | |||
server_name git.lfdb.com.br; | |||
return 301 https://git.lfdb.com.br$request_uri; | |||
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; | |||
rewrite ^/(.*) /$1 break; | |||
rewrite ^/$ /$1 break; | |||
proxy_read_timeout 90; | |||
} | |||
} | |||
server { | |||
server_name git.lfdb.com.br; | |||
listen 443 ssl; # managed by Certbot | |||
ssl_certificate /etc/letsencrypt/live/git.lfdb.com.br/fullchain.pem; # managed by Certbot | |||
ssl_certificate_key /etc/letsencrypt/live/git.lfdb.com.br/privkey.pem; # managed by Certbot | |||
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot | |||
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot | |||
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; | |||
rewrite ^/(.*) /$1 break; | |||
rewrite ^/$ /$1 break; | |||
proxy_read_timeout 90; | |||
} | |||
} | |||
``` | |||
* Comparativo da antiga configuração do arquivo `app.ini` para a nova configuração: | |||
* *alterações feitas no bloco `[server]`* | |||
```bash | |||
$ diff /opt/gogs/custom/conf/app.ini /opt/gogs/custom/conf/app.ini-old | |||
``` | |||
* Output: | |||
<source lang="bash"> | |||
17a18,20 | |||
> ROOT_URL = https://git.lfdb.com.br/ | |||
> CERT_FILE = /etc/letsencrypt/live/git.lfdb.com.br/cert.pem | |||
> KEY_FILE = /etc/letsencrypt/live/git.lfdb.com.br/privkey.pem | |||
19,20d21 | |||
< HTTP_PORT = 3000 | |||
< ROOT_URL = http://git.lfdb.com.br/ | |||
</source> | |||
http://blog.aeciopires.com/conhecendo-o-gogs/ | http://blog.aeciopires.com/conhecendo-o-gogs/ | ||
Edição das 20h21min de 14 de abril de 2019
Wiki referente a instalação e configuração do gogs.
- Gogs
Com nginx
- https://gogs.io/docs/intro/faqs
- https://discuss.gogs.io/t/gogs-is-not-working-with-nginx-https-proxy/309/6
- https://gist.github.com/thiemok/f7ad440c2d358e531e4a3945603420cd
- https://www.digitalocean.com/community/tutorials/how-to-set-up-gogs-on-ubuntu-14-04
Client / API
- Instalação
```bash apt install git mysql-server wget https://cdn.gogs.io/0.11.66/gogs_0.11.66_linux_amd64.tar.gz tar zxvf gogs_0.11.66_linux_amd64.tar.gz mv gogs /opt/ ```
```bash wget -O /etc/init.d/gogs https://gist.githubusercontent.com/leo-bianchi/a9581a42e478130ad4612a185151d385/raw/7bcc42930ba457d0c1b5e5ff173ad5d6a3e6a721/gogs ```
- Também pode ser encontrado [aqui](https://git.lfdb.com.br/lafabbrica/documentacao/raw/master/scripts_gogs/gogs)
```bash sed -i '18s/etc/opt/g' /etc/init.d/gogs chmod +x /etc/init.d/gogs useradd -m -d /home/git -s /bin/false git chown git: /home/git chown -R git: /opt/gogs/ /etc/init.d/gogs restart update-rc.d -f gogs defaults ```
- Criando base de dados
```bash mysql -u root -p ```
```sql GRANT ALL PRIVILEGES ON gogs.* TO 'gogs'@'localhost' identified by 'xu9AeMek'; ```
```sql CREATE DATABASE gogs CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci; ```
```sql flush privileges; ```
- SSL
- Para a implementação de SSL no nosso client gogs, utilizamos o [certbot](https://certbot.eff.org/).
- Configuração SSL
- Para a completa configuração do SSL no Gogs precisamos fazer alterações em dois arquivos de configuração: `app.ini` e o `arquivo de configuração do gogs no nginx`.
- Configuração atual do arquivo de configuração:
```nginx server {
listen 80; server_name git.lfdb.com.br;
return 301 https://git.lfdb.com.br$request_uri;
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;
rewrite ^/(.*) /$1 break;
rewrite ^/$ /$1 break;
proxy_read_timeout 90;
}
}
server { server_name git.lfdb.com.br;
listen 443 ssl; # managed by Certbot ssl_certificate /etc/letsencrypt/live/git.lfdb.com.br/fullchain.pem; # managed by Certbot ssl_certificate_key /etc/letsencrypt/live/git.lfdb.com.br/privkey.pem; # managed by Certbot include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
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;
rewrite ^/(.*) /$1 break;
rewrite ^/$ /$1 break;
proxy_read_timeout 90;
}
} ```
- Comparativo da antiga configuração do arquivo `app.ini` para a nova configuração:
* *alterações feitas no bloco `[server]`*
```bash $ diff /opt/gogs/custom/conf/app.ini /opt/gogs/custom/conf/app.ini-old ```
- Output:
17a18,20
> ROOT_URL = https://git.lfdb.com.br/
> CERT_FILE = /etc/letsencrypt/live/git.lfdb.com.br/cert.pem
> KEY_FILE = /etc/letsencrypt/live/git.lfdb.com.br/privkey.pem
19,20d21
< HTTP_PORT = 3000
< ROOT_URL = http://git.lfdb.com.br/