Skip to content

Commit d58888a

Browse files
committed
aguia-pescadora-alpha (#17): HTTPS em Alpha, baseado em arquivos de Bravo
1 parent 284d024 commit d58888a

File tree

6 files changed

+104
-24
lines changed

6 files changed

+104
-24
lines changed

logbook/aguia-pescadora-alpha.sh

Lines changed: 65 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,18 @@ exit
3434
#
3535
#------------------------------------------------------------------------------#
3636

37-
#### Preparação Inicial:
37+
#------------------------------------------------------------------------------#
38+
# SEÇÃO 0.1: Configuração inicial #
39+
# TL;DR: Isso é feito ao receber uma VPS do zero #
40+
#------------------------------------------------------------------------------#
41+
42+
### Primeiro login______________________________________________________________
43+
# Você, seja por usuario + senha, ou por Chave SSH, normlamente terá que acessar
44+
# diretamente como root. Excessões a esta regra (como VMs na AWS) geralmente
45+
# implicam em logar em um usuario não-root e executar como sudo. Mas nesta da
46+
# é por root mesmo nesse momento.
47+
ssh root@104.167.109.226
48+
3849

3950
# Aviso: a recomendação a seguir sobre 'Swap + /boot' é extremanente especifica
4051
# para uso na CloudAtCost. Outros provedores de VPSs tipicamente não requerem.
@@ -200,29 +211,6 @@ vim /usr/local/bin/ajuda
200211
####
201212
##### Customização de motd (Mensagem do dia), fim
202213

203-
##### Acesso HTTP e HTTPS, início
204-
####
205-
##
206-
#
207-
### NGinx
208-
## @see https://www.digitalocean.com/community/tutorials/como-instalar-o-nginx-no-ubuntu-16-04-pt
209-
sudo apt install nginx
210-
# sudo ufw allow 'Nginx Full' # Firewall desabilitado especialmente neste servidor
211-
212-
### Como Proteger o Nginx com o Let's Encrypt no Ubuntu 18.04:
213-
## @see https://www.digitalocean.com/community/tutorials/como-proteger-o-nginx-com-o-let-s-encrypt-no-ubuntu-18-04-pt
214-
sudo add-apt-repository ppa:certbot/certbot
215-
sudo apt-get update
216-
sudo apt-get install python-certbot-nginx
217-
218-
# Linha de comando para obter certificados. Automaticamente já edita configurações do NGinx
219-
sudo certbot --nginx -d aguia-pescadora.etica.ai -d www.aguia-pescadora.etica.ai
220-
221-
#
222-
##
223-
####
224-
##### Acesso HTTP e HTTPS, Fim
225-
226214
##### Ambientes de desenvolvimento / Linguagens de programação, inicio
227215

228216
##### Ambientes de desenvolvimento / Linguagens de programação
@@ -421,6 +409,59 @@ sudo systemctl reload haproxy
421409
## Teste se o usuario do haproxy consegue acessar
422410
mysql -h elefante-borneu-yul-01.etica.ai -u haproxy
423411

412+
#------------------------------------------------------------------------------#
413+
# SEÇÃO: HTTP/HTTPS PADRÃO #
414+
# TL;DR: Documenta o uso de NGinx e afins como proxy reverso a aplicações #
415+
# internas. Os colaboradores podem solicitar endereços customizados #
416+
# (como domínios de todo gratuitos no freenom.com) que incluimos também #
417+
# nas configurações do servidor #
418+
#------------------------------------------------------------------------------#
419+
420+
##### Sites Habilitados neste servidor _________________________________________
421+
# Cada usuário, mesmo sem acesso sudo (super usuário) pode chamar aplicações
422+
# em portas acima da 1024, como em http://apb.etica.ai:3000. A lista a seguir
423+
# são ou padrão de sistema, ou que usuários pediram para rotear via HTTP e HTTPS
424+
# para uma de suas aplicações internas.
425+
#
426+
# - http://aguia-pescadora-alpha.etica.ai
427+
# - https://aguia-pescadora-alpha.etica.ai
428+
# - http://apa.etica.ai
429+
# - https://apa.etica.ai
430+
431+
##### NGinx ____________________________________________________________________
432+
## @see http://nginx.org/
433+
## @see https://www.digitalocean.com/community/tutorials/como-instalar-o-nginx-no-ubuntu-16-04-pt
434+
sudo apt install nginx
435+
# sudo ufw allow 'Nginx Full' # Firewall desabilitado especialmente neste servidor
436+
437+
### Como Proteger o Nginx com o Let's Encrypt no Ubuntu 18.04:
438+
## @see https://www.digitalocean.com/community/tutorials/como-proteger-o-nginx-com-o-let-s-encrypt-no-ubuntu-18-04-pt
439+
sudo add-apt-repository ppa:certbot/certbot
440+
sudo apt-get update
441+
sudo apt-get install python-certbot-nginx
442+
443+
sudo vim /etc/nginx/sites-available/aguia-pescadora-alpha.etica.ai.conf
444+
# Adicione todas as customizacoes deste usuario no arquivo acima...
445+
446+
sudo ln -s /etc/nginx/sites-available/aguia-pescadora-alpha.etica.ai.conf /etc/nginx/sites-enabled/
447+
sudo nginx -t
448+
sudo systemctl reload nginx
449+
450+
# Linha de comando para obter certificados. Automaticamente já edita configurações do NGinx
451+
sudo certbot --nginx -d aguia-pescadora-alpha.etica.ai -d apa.etica.ai
452+
453+
454+
### Userdir
455+
# Userdir não implementado em Alpha
456+
457+
458+
# PROTIP: acompanhe os arquivos a seguir para debugar
459+
# tail -f /var/log/nginx/access.log
460+
# tail -f /var/log/nginx/error.log
461+
# Em geral o principal motivo de erro serão permissões de arquivo e de
462+
# diretório até o respectivo arquivo
463+
464+
424465

425466
#------------------------------------------------------------------------------#
426467
# SEÇÃO: OUTROS #
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# FILE: /etc/nginx/sites-available/aguia-pescadora-alpha.etica.ai.conf
2+
# SERVER: aguia-pescadora-alpha.etica.ai
3+
4+
server {
5+
6+
listen 80;
7+
listen [::]:80;
8+
root /var/www/html;
9+
10+
index index.html index.htm index.nginx-debian.html;
11+
12+
server_name apa.etica.ai aguia-pescadora-alpha.etica.ai;
13+
14+
location / {
15+
try_files $uri $uri/ =404;
16+
}
17+
18+
listen [::]:443 ssl ipv6only=on; # managed by Certbot
19+
listen 443 ssl; # managed by Certbot
20+
ssl_certificate /etc/letsencrypt/live/aguia-pescadora-alpha.etica.ai/fullchain.pem; # managed by Certbot
21+
ssl_certificate_key /etc/letsencrypt/live/aguia-pescadora-alpha.etica.ai/privkey.pem; # managed by Certbot
22+
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
23+
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
24+
25+
26+
}

logbook/aguia-pescadora-alpha/etc/nginx/sites-available/aguia-pescadora.etica.ai

Whitespace-only changes.

logbook/aguia-pescadora-alpha/etc/nginx/sites-available/default

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# FILE: /etc/nginx/sites-available/default
2+
# SERVER: aguia-pescadora-alpha.etica.ai
3+
14
##
25
# You should look at the following URL's in order to grasp a solid understanding
36
# of Nginx configuration files in order to fully unleash the power of Nginx.

logbook/aguia-pescadora-alpha/etc/nginx/sites-available/haproxy.apa.etica.ai.conf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,11 @@ server {
1212
proxy_pass http://127.0.0.1:1936;
1313
}
1414

15+
16+
listen 443 ssl; # managed by Certbot
17+
ssl_certificate /etc/letsencrypt/live/haproxy.apa.etica.ai/fullchain.pem; # managed by Certbot
18+
ssl_certificate_key /etc/letsencrypt/live/haproxy.apa.etica.ai/privkey.pem; # managed by Certbot
19+
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
20+
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
21+
1522
}

logbook/aguia-pescadora-bravo/etc/nginx/sites-available/default

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# FILE: /etc/nginx/sites-available/default
2+
# SERVER: aguia-pescadora-bravo.etica.ai
3+
14
##
25
# You should look at the following URL's in order to grasp a solid understanding
36
# of Nginx configuration files in order to fully unleash the power of Nginx.

0 commit comments

Comments
 (0)