Развертывание Gogs.
В этой заметки: установка и настройка легковесного git репозитория написанного на go,создание самоподписанных ssl сертификатов, настройка nginx как прокси сервера для https, а также настройка ufw для блокировки нежелательных подключений по 80 и 3000 порту.
Установка gogs на Ubuntu 20.04 LTS.
Устанавливаем git и sqlite3.
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Создаем пользователя для gogs.
Скачиваем архив с бинарным файлом gogs используя wget с сайта.
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Разархивируем скаченный архив.
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Переносим папку gogs в созданный ранее каталог /home/git. Изменяем владельца каталога и файлов в нем на git:git.
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Скопируем готовый файл модуля systemd в каталог с сервисами.
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Запускаем сервис. И добавляем в автозагрузку.
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Перейдем по ip_адрес-сервера:3000. И продожаем web установку. Выбираем базу данный SQLite3. Указываем полный путь до файла бд /home/git/gogs/gogs.db.
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Указываем в разделе домен адрес нашего сервера или DNS имя сервера.
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Жмем установить gogs. После ждем минутку и обновляем страницу. Нажимаем на регистрацию. Создайем аккаунт. Первый созданный аккаунт это будет аккаунт администратора gogs.
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Входим в аккаунт.
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Настройка nginx в качестве прокси сервера завершения ssl.
Мы можем с вами заметить что по умолчанию gogs использует протокол http что не является безопасным.
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Для решения этой проблемы настроим Nginx в качестве прокси завершения ssl. Устанавливаем nginx. Создаем директорию /etc/nginx/ssl. Генерируем самоподписанный ssl сертификат.
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Создайем конфиг gogs_ssl.conf в директории /etc/nginx/conf.d. В proxy_pass указываем адрес сервера gogs. Не забываем удалить стандартный сайт Nginx или отключить его если используеться IP адресс вместо dns имени.
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Теперь мы можем переходит на сайт по https без указания порта.
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Настройка ufw для блокировки 80 и 3000 портов.
На сайт можно до сих пор зайти по 3000 порту это дыра в системе и стоит это исправить. Установите ufw. Ufw это надстройка над IPtables с более дружелюбным способом создавать правила.
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Перед тем как что то блокировать и запускать ufw создаем правило разрешающие ssh подключения в ufw это делается просто:
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Теперь нам нужно разрешить подключения по https.
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
По умолчанию после включение ufw все не указанные как разрешенные порты будут блокироваться. Поэтому блокировать 3000 порт нам не нужно. Однако нужно создать разрешающие правило для подключения на этот порт с нашего Nginx proxy.
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Запускаем ufw. И смотрим статус.
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Теперь при попытки подключиться по http мы будет получать такое сообщение от браузера, тоже самое, будет и по 3000 порту. Зато по https у нас все будет прекрасно работать.
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Работа по https.
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Тестирование Gogs.
Давайте проверим работоспособность нашей системы контроля версий gogs.
Создаем репозиторий.
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Мы попадем на такую страницу.
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Открываем свой любимый редактор кода в моем случае это vscode. Открываем терминал, отключаем проверку ssl гитом и добавляем репозиторий.
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Создаем файл Readme.md
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Закоммитьтем изменения.
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Залеваем обновления в репозиторий. Нас спросит логин и пароль указываем логин пароль созданного ранее аккаунта.
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Обновляем страницу репозитория в браузере. Как можно увидеть появился файл Readme.md.
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
Отключать проверку ssl сертификата не рекомендую с точки зрения безопасности, поэтому после тестирование верните в значение true. В обычной ситуации вам нужно было бы добавлять созданный нами сертификат в доверенные для нашего ПК с git. Но еще более вероятно мы бы использовали сертификат подписанный доверенным центром сертификации.