{"id":15062161,"url":"https://github.com/zenepay/https-localhost-docker","last_synced_at":"2025-04-10T10:04:14.217Z","repository":{"id":257707430,"uuid":"859084239","full_name":"zenepay/https-localhost-docker","owner":"zenepay","description":"This enables to localhost dev environment using nginx proxy to route to other docker containers. This also includes mariadb database.","archived":false,"fork":false,"pushed_at":"2025-03-17T02:39:22.000Z","size":167,"stargazers_count":15,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-24T08:54:41.471Z","etag":null,"topics":["docker","https","https-proxy","localhost","maraidb-datatabase","phpmyadmin","ssl"],"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/zenepay.png","metadata":{"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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-18T03:56:19.000Z","updated_at":"2025-03-17T02:39:25.000Z","dependencies_parsed_at":"2025-01-31T04:20:23.087Z","dependency_job_id":"700623af-e59a-4696-868c-7bc6418468c0","html_url":"https://github.com/zenepay/https-localhost-docker","commit_stats":null,"previous_names":["zenepay/https-localhost-docker"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zenepay%2Fhttps-localhost-docker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zenepay%2Fhttps-localhost-docker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zenepay%2Fhttps-localhost-docker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zenepay%2Fhttps-localhost-docker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zenepay","download_url":"https://codeload.github.com/zenepay/https-localhost-docker/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248198878,"owners_count":21063627,"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":["docker","https","https-proxy","localhost","maraidb-datatabase","phpmyadmin","ssl"],"created_at":"2024-09-24T23:31:17.153Z","updated_at":"2025-04-10T10:04:14.192Z","avatar_url":"https://github.com/zenepay.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# Dev systems with docker for with ssl for local host\n\n## Installation\nIn your home workspace eg\n/home\n/home/project1\n/home/project2\n\nWe will clone our nginx call sail_share to home directory\n/home/sail_share\n\n```sh\ncd /home\ngit clone https://github.com/zenepay/https-localhost-docker.git sail_share\ncd sail_share\n\n```\n\n\nThis will make 3 docker images for:\n1. nginx to route url eg project1.dev.localhost where project1 is running ohter ports eg 8801\n2. mariadb database port 3306\n3. phpmyadmin to mange mariadb port: 8890\n\n### Setup SSL on localhost\n## Step 1: Generate a CA Certificate\n~~~sh\nmkdir nginx-certs\ncd nginx-certs\nopenssl genrsa -out ca.key -des3 2048\nopenssl req -x509 -sha256 -new -nodes -days 3650 -key ca.key -out ca.pem\n\n~~~\n\n## Step 2: Generate Certificate, Signed By Our CA\nWe already has resources/localhost.ext file, if not yet exist here please using this:\n~~~conf\nauthorityKeyIdentifier=keyid,issuer\nbasicConstraints=CA:FALSE\nkeyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment\nextendedKeyUsage = serverAuth, clientAuth\nsubjectAltName = @alt_names\n[req]\nreq_extensions = req_ext\n[req_distinguished_name]\ncommonName_default = localhost\n[req_ext]\nsubjectAltName = @alt_names\n[alt_names]\nDNS.1 = *.dev.localhost\nDNS.2 = dev.localhost\nDNS.3 = localhost\n~~~\n\nNow generate locahost.key file with this command\n### Generate a private key\nChoose a simple passphrase eg. NginXpass for your key. Enter it, re-enter it.\nYou are still in the resources folder\n~~~sh\nopenssl genrsa -out localhost.key -des3 2048\n~~~\n -Generate certificate signing request using key.\n -Enter the passphrase eg. NginXpass that you chose for the key -Choose defaults or enter information as appropriate.\n Don't worry about entering anything for \"challenge password\"\n~~~sh\nopenssl req -new -key localhost.key -out localhost.csr\n~~~\n### Use the passphrase that you chose for the CA KEY in Step 1.\n~~~sh\nopenssl x509 -req -in localhost.csr -CA ca.pem -CAkey ca.key \\\n-CAcreateserial -days 3650 -sha256 \\\n-extfile ../resources/localhost.ext -out localhost.crt\n~~~\n\n Use the passphrase eg. NginXpass chosen for the localhost key,\n which is NOT the same as the CA key.\n~~~sh\nopenssl rsa -in localhost.key -out localhost.decrypted.key\n ~~~\n## Step 3: Import CA Certificate to Browsers\nin brownser chrome put url as:\nchrome://settings/certificates\nClick Import then browse to nginx-certs/ca.pem\nClick on the box that says “Trust this certificate for identifying websites.” Click on “OK.”\n\n## Step 4: set ip for host in hosts file\nC:\\Windows\\System32\\drivers\\etc\\hosts\neg:\n\n```\n127.0.0.1 kubernetes.docker.internal localhost mariadb dev.localhost *.dev.localhost\n\n192.168.1.111 host.docker.internal\n192.168.1.111 gateway.docker.internal\n```\n\n## Setp 4.1 set db host in wsl host file\nsh~~~\nsudo nano /etc/hosts\n~~~\nAdd mysql and mariadb at line localhost\n~~~\n172.0.0.1 localhost mysql mariadb\n~~~\n## Step 5: edit global.pass\nChange your file /nginx/keys/global.pass eg. NginXpass by enter your passphase of the key created above\n\n## Step 6: edit default.conf.template\nChange server_name to the subdomain, you want\nChage port to where the docker image is run eg port 8000\nproxy_pass\thttp://host.docker.internal:8000;\n```\n#for default local nginx hosting\nserver {\n    listen  443 ssl;\n    server_name dev.localhost;\n    root /var/www/html;\n\n    ssl_certificate     /etc/nginx/certs/localhost.crt;\n    ssl_certificate_key /etc/nginx/certs/localhost.key;\n\n    location / {\n        index index.php index.html;\n    }\n    location ~ \\.php$ {\n        include fastcgi_params;\n        fastcgi_pass php:9000;\n        fastcgi_index index.php;\n        fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;\n    }\n}\n#for forward proxy hosint with docker or other ports\nserver {\n    listen  443 ssl;\n    server_name subdomain.dev.localhost;\n\n    # Self signed certificates\n    # Don't use them in a production server!\n    ssl_certificate     /etc/nginx/certs/localhost.crt;\n    ssl_certificate_key /etc/nginx/certs/localhost.key;\n\n    location / {\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 Host $host;\n        proxy_set_header X-Forwarded-Proto $scheme;\n        proxy_pass\thttp://host.docker.internal:8000;\n    }\n}\n```\n## Step 7: set network of your docker project to the same\nEdit your docker-compose.yml on your docker project (not this project)\nmust have network zen-network and external: true as below\n```\nnetworks:\n    sail:\n        driver: bridge\n        name: zen-network\n        external: true\n```\n## Step 8: create with docker compose\ncreate .env file\n```sh\ncd ..\nmv .env.example .env\nmkdir mariadb\n```\nNow open Docker Desktop to let it start the service,\nafter that run following to build the image\n~~~sh\ndocker compose up\n~~~","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzenepay%2Fhttps-localhost-docker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzenepay%2Fhttps-localhost-docker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzenepay%2Fhttps-localhost-docker/lists"}