Skip to content

Commit 4b1ba6f

Browse files
committed
[WIP] Add quickstart guide for ohttp-relay on basic ubuntu server
This issue payjoin/ohttp-relay#37 outlines a need for some documentation for a quickstart guide on a docker server with a nginx proxy.
1 parent 9ea05ed commit 4b1ba6f

1 file changed

Lines changed: 94 additions & 0 deletions

File tree

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# Quickstart ohttp relay
2+
3+
We'll demonstrate how you can setup an ohttp server on common cloud insfrastructure on something like [AWS Ubunut](https://docs.aws.amazon.com/kinesisvideostreams/latest/dg/gs-ubuntu.html) using the `ohttp-relay` crate in Payjoin Dev Kit. This should take about 30 minutes.
4+
5+
## Initial server setup
6+
7+
We will be using a basic Ubuntu server in our tutorial. In this tutorial we will be running the server as a docker container with nginx as a TLS proxy.
8+
9+
First, you must install docker and nginx on your server.
10+
11+
Install docker, nginx and the ningx stream module on a fresh Ubuntu server:
12+
13+
```sh
14+
sudo apt update && sudo apt upgrade -y # Ubuntu
15+
16+
sudo apt install -y docker.io nginx libnginx-mod-stream #This lib will give us access to the nginx stream module
17+
18+
sudo systemctl start docker nginx
19+
sudo systemctl enable docker nginx
20+
```
21+
22+
## Deploy ohttp-relay with Docker
23+
24+
We will want to build our docker image for our server to run as a container from.
25+
26+
Clone our ohttp-relay from github and then build the docker image.
27+
28+
```sh
29+
git clone https://github.com/payjoin/ohttp-relay.git
30+
31+
cd ohttp-relay
32+
33+
sudo docker build -t ohttp-relay .
34+
```
35+
36+
## Configure Nginx as a Reverse Proxy
37+
38+
Edit the existing `nginx.conf`.
39+
40+
```sh
41+
#/etc/nginx/nginx.conf
42+
load_modules /usr/lib/nginx/modules/ngx_mod_stream.so;
43+
error_log /var/log/nginx/error.log debug;
44+
pid /var/run/nginx.pid;
45+
46+
events {
47+
worker_connections 1024;
48+
}
49+
50+
stream {
51+
server {
52+
listen 80;
53+
54+
proxy_pass 127.0.0.1:8080;
55+
}
56+
57+
server {
58+
listen 443 ssl;
59+
60+
ssl_certificate /etc/nginx/ssl/cert.pem;
61+
ssl_certificate_key /etc/nginx/ssl/key.pem;
62+
63+
proxy_pass 127.0.0.1:8080;
64+
}
65+
}
66+
67+
```
68+
69+
Restart your nginx service
70+
71+
```sh
72+
sudo systemctl restart nginx
73+
```
74+
75+
## Ensure the ohttp-relay runs persistently
76+
77+
We can use some built-in flags in docker to run our ohttp-relay in the background.
78+
79+
```sh
80+
sudo docker run -d --restart unless-stopped --name ohttp-relay -p 8080:8080 \
81+
-e PORT=8080 \
82+
-e GATEWAY_ORIGIN='https://your-upstream-gateway.com' \
83+
your-dockerhub-username/ohttp-relay
84+
```
85+
86+
the `-d` flag ensures that our container will be running in the background and `--restart unless stopped` will ensure persistence even after logging and server reboots.
87+
88+
That's all it takes to setup an ohttp-relay. The looping allows a sender to send a proposal and receive a Payjoin in an asynchronous way. When you run this program you will participate in coordinating payjoins by relaying data between senders and receivers without .
89+
90+
Check your work by running the curl request below to do a quick check to make sure your server is receiving well.
91+
92+
```sh
93+
curl -vk --request POST https://35.87.199.174 -H "Content-Type: application/json" --data '{//figure out a good request body for testing//}'
94+
```

0 commit comments

Comments
 (0)