{"id":20812181,"url":"https://github.com/sertxudeveloper/environment","last_synced_at":"2025-03-12T04:45:06.581Z","repository":{"id":46624236,"uuid":"273258726","full_name":"sertxudeveloper/environment","owner":"sertxudeveloper","description":"Sertxu Developer environment","archived":false,"fork":false,"pushed_at":"2022-09-04T21:30:34.000Z","size":60,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-18T14:51:25.495Z","etag":null,"topics":["bind9","dns","docker","environment","hacktoberfest","http","http2","mysql","nginx","php","reverse-proxy","sertxudeveloper","vagrant"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sertxudeveloper.png","metadata":{"funding":{"github":["sertxudev"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":["https://buymeacoffee.com/sertxudeveloper"]},"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-06-18T14:22:58.000Z","updated_at":"2022-12-04T11:29:01.000Z","dependencies_parsed_at":"2023-01-17T20:47:13.304Z","dependency_job_id":null,"html_url":"https://github.com/sertxudeveloper/environment","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sertxudeveloper%2Fenvironment","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sertxudeveloper%2Fenvironment/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sertxudeveloper%2Fenvironment/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sertxudeveloper%2Fenvironment/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sertxudeveloper","download_url":"https://codeload.github.com/sertxudeveloper/environment/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243158972,"owners_count":20245669,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bind9","dns","docker","environment","hacktoberfest","http","http2","mysql","nginx","php","reverse-proxy","sertxudeveloper","vagrant"],"created_at":"2024-11-17T20:51:05.000Z","updated_at":"2025-03-12T04:45:06.547Z","avatar_url":"https://github.com/sertxudeveloper.png","language":"Shell","readme":"# Dev Environment\n\nThis environment is used as a server with virtualization using Docker.\n\n## System requirements\n\n- Virtualbox\n- Vagrant\n\n## Installation\n\nFirst you should create the VM using Vagrant.\n\n```\nC:\\\u003e vagrant up\n```\n\nOnce Vagrant has ended creating the VM, we must execute as root the init.sh file inside the VM.\n\n```\nC:\\\u003e vagrant ssh\n$ sudo bash init.sh\n```\n\n## Build images\n\nAfter the script has installed Docker, Nginx and Bind9, we must build the docker images.\u003cbr\u003e\nThese images are located at `/vagrant/home/@images`.\n\n```\n$ cd /vagrant/home/@images\n\n$ docker build -t laravel:1.0 laravel\n```\n\n\n## Create new project\n\nTo create a new project, first we should create the required folders inside the `home` environment folder.\u003cbr\u003e\nAs an example we're going to create a Laravel project with the `sertxudeveloper.test` domain.\n\nThe contents will have the following structure.\n\n- Vagrantfile\n- create.sh\n- init.sh\n- home/\n  - @images\n  - sertxudeloper.test\n    - run.sh\n    - data\n\nNext we sould link the project folder located at the `home` environment folder with the system `home` folder.\n\n```\n$ sudo ln -s /vagrant/home/sertxudeveloper.test /home/sertxudeveloper.test\n```\n\n### Configure domain\n\nOur environment has its own DNS server, we should create the DNS zone for the new domain.\n\n```\n$ sudo vi /etc/bind/named.conf.test\n```\n\n```\n...\nzone \"sertxudeveloper.test\" {\n    type master;\n    file \"/etc/bind/db.sertxudeveloper.test\";\n};\n```\n\n-----\n\n```\n$ sudo vi /etc/bind/db.sertxudeveloper.test\n```\n\n```\n$TTL 1d\n$ORIGIN sertxudeveloper.test.\n\n@ IN SOA sertxudeveloper.test. admin.sertxudeveloper.test. (\n20200714 8h 15m 4w 1d)\n\n* IN CNAME sertxudeveloper.test.\n\n@ IN NS sertxudeveloper.test.\n@ IN A 10.0.0.30\n```\n\n-----\n\n```\n$ sudo systemctl restart bind9\n```\n\n### Create SSL certificate\n\nWe should create a SSL certificate to be able to use HTTPS when accessing our project.\n\nOur environment has its own root CA certificates so the browser can trust the self-signed certificates.\n\nTo create the certificate we must execute the `create.sh` script.\n\n```\n$ sudo bash create.sh\n```\n\nIt will ask for the domain we want to generate the certificate, and will create a wildcard certificate so we only need one for all the subdomains.\n\n\n### Configure reverse proxy\n\nTo be able to access our project we need to configure a reverse proxy.\n\n```\n$ sudo vi /etc/nginx/sites-available/sertxudeveloper.test\n```\n\n```nginx\nserver {\n    listen 80;\n    server_name sertxudeveloper.test;\n    server_name www.sertxudeveloper.test;\n\n    return 301 https://www.sertxudeveloper.test$request_uri;\n}\n\nserver {\n    listen 443 ssl;\n    server_name sertxudeveloper.test;\n\n    return 301 https://www.sertxudeveloper.test$request_uri;\n}\n\nserver {\n    listen 443 ssl;\n    server_name www.sertxudeveloper.test;\n\n    ssl_certificate /home/sertxudeveloper.test/nginx.pem;\n    ssl_certificate_key /home/sertxudeveloper.test/nginx.key;\n\n    location / {\n        proxy_pass http://172.18.1.2;\n        proxy_set_header Host $host;\n        proxy_set_header X-Real-IP $remote_addr;\n        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\n        proxy_set_header X-Forwarded-Proto $scheme;\n    }\n}\n```\n\n-----\n\nOnce we saved the reverse proxy configuration, we need to enable the site.\n\n```\n$ sudo ln -s /etc/nginx/sites-available/sertxudeveloper.test /etc/nginx/sites-enabled/sertxudeveloper.test\n```\n\n```\n$ sudo systemctl restart nginx\n```\n\n## Trust SSL root CA\n\nWe need to add the root CA certificate to the local trusted entities.\n\n### Ubuntu guest\n\n```\n$ sudo cp /vagrant/rootCA.crt /usr/local/share/ca-certificates/\n$ sudo update-ca-certificates --fresh\n```\n\n### Docker container\n\n```\n$ docker cp /vagrant/rootCA.pem {container name}:/usr/local/share/ca-certificates\n$ docker exec {container name} rm -f /usr/local/share/ca-certificates/certificate.crt\n$ docker exec {container name} ln -s /usr/local/share/ca-certificates/rootCA.pem /etc/ssl/certs/\n$ docker exec {container name} update-ca-certificates --fresh\n```\n\n## Change folders and files permissions\n\n```\nmkdir data\nchown -R root:www-data data\nchmod -R 2770 data\nfind data -type d -exec chmod 770 {} \\;\nfind data -type f -exec chmod 660 {} \\;\n```\n\n","funding_links":["https://github.com/sponsors/sertxudev","https://buymeacoffee.com/sertxudeveloper"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsertxudeveloper%2Fenvironment","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsertxudeveloper%2Fenvironment","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsertxudeveloper%2Fenvironment/lists"}