Skip to content

Commit d6c12a6

Browse files
author
Jonathan Visser
committed
Add document "How to set up an application proxy in Nginx?"
1 parent 4587bd9 commit d6c12a6

1 file changed

Lines changed: 50 additions & 0 deletions

File tree

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
---
2+
myst:
3+
html_meta:
4+
description: Learn how to set up an Nginx application proxy on Hypernode using Managed Vhosts: create a proxy vhost and point it to your app
5+
title: How to set up an application proxy in Nginx? | Hypernode
6+
---
7+
8+
# How to Set Up an Application Proxy in Nginx
9+
10+
Sometimes you want to serve an application that listens on a local port (for example a Node, Python or PHP service on `localhost:3000`) behind a friendly domain on your Hypernode. Instead of writing a custom Nginx config, you can use Hypernode Managed Vhosts to generate a ready‑made proxy vhost coniguration and then just point it to your application. This keeps your configuration simple and consistent with the rest of your setup.
11+
12+
## Create a proxy vhost
13+
14+
Create a new vhost and set its type to `proxy`. In the example below we create a vhost for `proxy.myapp.hypernode.io`:
15+
16+
```bash
17+
app@abc123-myapp-magweb-cmbl:~$ hmv proxy.myapp.hypernode.io --type proxy
18+
INFO: Managing configs for proxy.myapp.hypernode.io
19+
INFO: No existing config for proxy.myapp.hypernode.io, starting with default options
20+
INFO: Writing HTTP config for proxy.myapp.hypernode.io
21+
```
22+
23+
This command creates a vhost directory under `/data/web/nginx/<your-domain>/` with the proxy templates. You will see the following files:
24+
25+
```bash
26+
app@abc123-myapp-magweb-cmbl:~/nginx/proxy.myapp.hypernode.io$ ls
27+
public.proxy.conf server.rewrites.conf staging.proxy.conf
28+
```
29+
30+
## Point the proxy to your application
31+
32+
Open `public.proxy.conf`. The only lines you normally need to change are at the top: the upstream host and port your application listens on. By default they point to `localhost:3000`.
33+
34+
```nginx
35+
app@abc123-app-magweb-cmbl:~/nginx/proxy.myapp.hypernode.io$ cat public.proxy.conf
36+
set $app_proxy_host localhost;
37+
set $app_proxy_port 3000;
38+
39+
root /data/web/public;
40+
41+
include /etc/nginx/app_proxy_handler.conf;
42+
43+
location / {
44+
echo_exec @app_proxy_handler;
45+
}
46+
```
47+
48+
Replace `localhost` and `3000` with the correct target for your app if it listens elsewhere. You generally do not need to change anything below those two lines. The included `app_proxy_handler.conf` wires up sensible proxy defaults, SSL, headers and buffering for you. Save the file and Nginx will apply the change.
49+
50+
If you also plan to use the staging mode of this vhost, mirror the same host and port settings in `staging.proxy.conf` so that the staging switch serves the same upstream.

0 commit comments

Comments
 (0)