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!

API Trace View

How I Cut 22.3 Seconds Off an API Call with Sentry 👀

Struggling with slow API calls? Dan Mindru walks through how he used Sentry's new Trace View feature to shave off 22.3 seconds from an API call.

Get a practical walkthrough of how to identify bottlenecks, split tasks into multiple parallel tasks, identify slow AI model calls, and more.

Read more →

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay