Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
casimiro committed Aug 17, 2023
1 parent 30019bc commit 035fd34
Show file tree
Hide file tree
Showing 3 changed files with 297 additions and 229 deletions.
59 changes: 59 additions & 0 deletions .github/actions/setup-echo-server/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: setup-echo-server
decription: |
This action sets up an echo server associating a name to it.
The name, e.g. `httpbin.org`, will be resolved to 127.0.0.1 by dnsmasq.
inputs:
upstream_dns_server:
description: 'DNS server used by dnsmasq to resolve entries not yet cached'
required: false
default: '1.1.1.1'
echo_server_name:
description: 'A name dnsmasq will resolve to 127.0.0.1, e.g.: httpbin.org'
required: false

runs:
using: "composite"
steps:
- run: sudo apt-get install -y dnsmasq
if: ${{ matrix.os == 'ubuntu-latest' || matrix.os == 'ubuntu-22.04' }}
shell: bash
- run: brew install dnsmasq
if: ${{ matrix.os == 'macos-latest' }}
shell: bash

- run: |
sudo systemctl stop systemd-resolved
sudo dnsmasq --no-hosts \
--no-resolv \
--server=${{ inputs.upstream_dns_server }} \
--address=/${{ inputs.echo_server_name }}/127.0.0.1
shell: bash
- run: |
cat <<EOT >> /tmp/nginx.conf
server {
listen 80;
server_name '${{ inputs.echo_server_name }}';
listen 443 ssl;
server_name '${{ inputs.echo_server_name }}';
ssl_protocols TLSv1.2;
ssl_certificate /etc/nginx/hostname_cert.pem;
ssl_certificate_key /etc/nginx/hostname_key.pem;
location / {
proxy_pass http://httpbin;
}
}
EOT
docker run --name httpbin -d kennethreitz/httpbin
docker run --name httpbin_proxy \
--link httpbin \
-p 80:80 \
-p 443:443 \
-v /tmp/nginx.conf:/etc/nginx/nginx.conf.d/httpbin.conf:ro \
-v ./t/data/hostname_cert.pem:/etc/nginx/hostname_cert.pem:ro \
-v ./t/data/hostname_key.pem:/etc/nginx/hostname_key.pem:ro \
-d nginx
shell: bash
Loading

0 comments on commit 035fd34

Please sign in to comment.