DEV Community

Ambassador
Ambassador

Posted on • Originally published at getambassador.io

1

Host a Reverse Proxy in Seconds

Need a publicly accessible reverse proxy? Want to skip testing with localhost? Blackbird has an easy solution.
Blackbird API Development

Setting up the Proxy

First let’s configure a simple reverse proxy with nginx using the following nginx.conf:

server {
listen 80;
location / {
proxy_pass "https://httpbin.org/";
}
}

All requests sent to this server will proxy out to httpbin.org — a nice tool for developing and testing this proxy with downstream servers/APIs.

Next, we’ll define a simple Dockerfile that uses our ngnix configuration to build an image:

`
FROM nginx:latest

COPY nginx.conf /etc/nginx/conf.d/default.conf`

EXPOSE 80

Hosting the Proxy with Blackbird

After installing the Blackbird CLI, we can publicly host this reverse proxy with a Blackbird deployment:

blackbird deployment create proxy -d Dockerfile -c .
✔ input validated
✔ environment is ready
✔ no matching mock instance found
✔ image successfully built
✔ image successfully pushed
✔ checking existing deployments
✔ creating application for deployment
✔ application deployment created
+-------+------------+----------+---------------------------------------------------------+
| NAME | TYPE | STATUS | URL |
+-------+------------+----------+---------------------------------------------------------+
| proxy | deployment | Ready | https://matts-org-a0696.blackbird-relay.a8r.io/proxy/ |
+-------+------------+----------+---------------------------------------------------------+

Blackbird gave us a public host that is running our reverse proxy in a container - let’s try it out:

curl --request POST -d '{"message":"hello"}' \
https://matts-org-a0696.blackbird-relay.a8r.io/proxy/post

{
"args": {},
"data": "{\"message\":\"hello\"}",
"files": {},
"form": {},
"headers": {
"Accept": "*/*",
"Content-Length": "19",
"Content-Type": "application/json",
"Host": "httpbin.org",
"User-Agent": "curl/8.6.0"
},
"json": {
"message": "hello"
},
"url": "https://httpbin.org/post"
}

Just like that, our reverse proxy is live and hosted 🚀

Happy proxying!

Speedy emails, satisfied customers

Postmark Image

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

Heroku

Build apps, not infrastructure.

Dealing with servers, hardware, and infrastructure can take up your valuable time. Discover the benefits of Heroku, the PaaS of choice for developers since 2007.

Visit Site

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay