Skip to content

Commit

Permalink
Merge branch 'master' into next
Browse files Browse the repository at this point in the history
  • Loading branch information
potts99 authored Dec 12, 2023
2 parents 98226f0 + 4baaaab commit ef6faff
Show file tree
Hide file tree
Showing 7 changed files with 736 additions and 14 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ services:
depends_on:
- peppermint_postgres
healthcheck:
test: ["CMD", "sh", "-c", "wget --spider $$BASE_URL"]
test: ["CMD", "sh", "-c", "wget --spider $$API_URL"]
interval: 30s
timeout: 10s
retries: 3
Expand Down Expand Up @@ -123,6 +123,9 @@ Give a ⭐️ if this project helped you!

[![Star History Chart](https://api.star-history.com/svg?repos=Peppermint-Lab/peppermint&type=Date)](https://star-history.com/#Peppermint-Lab/peppermint&Date)

## Activity
![Alt](https://repobeats.axiom.co/api/embed/9b568eb9e41b60f60fe155836b1ef0fb2a7b93b9.svg "Repobeats analytics image")

## Author

👤 **Jack Andrews**
Expand Down
55 changes: 50 additions & 5 deletions apps/docs/pages/reverse-proxy.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ https://support.example.com

Behind the scenes you'll most likely use nginx, trafik or haproxy to achieve this goal. In this example we will be using nginx on debian.

In the end, you should have a setup like so:

```
https://peppermint.example.com -> https://peppermintapi.example.com -> nginx -> peppermint docker
```

I know two different subdomains may seem a bit overkill, but this is the only way to achieve this goal.

## Setting up the box & nginx

In this example, I'm going to be using a node provided by linode pre-installed with docker, but any vm should be able to achieve this provided they have a static i.p address.
Expand Down Expand Up @@ -64,6 +72,8 @@ Lets enable that now
sudo ufw allow 'Nginx HTTP'
```

Use https if you have SSL cert enabled.

### Checking nginx

To make sure nginx is running okay when can run the command:
Expand Down Expand Up @@ -140,7 +150,7 @@ services:
depends_on:
- peppermint_postgres
healthcheck:
test: ["CMD", "sh", "-c", "wget --spider $$BASE_URL"]
test: ["CMD", "sh", "-c", "wget --spider $$API_URL"]
interval: 30s
timeout: 10s
retries: 3
Expand All @@ -149,7 +159,7 @@ services:
DB_PASSWORD: "1234"
DB_HOST: "peppermint_postgres"
SECRET: 'peppermint4life'
API_URL: "http://server-ip:5003"
API_URL: "https://peppermintapi.example.com"
volumes:
pgdata:
Expand All @@ -169,7 +179,7 @@ This will pull the peppermint image & postgres and start the process of both con

### Nginx config

Now that nginx is set up & both are containers are working, we can now implement the config file which is going to route our proxy to our subdomain.
Now that nginx is set up & both are containers are working, we can now implement the config file which is going to route our proxy to our subdomains.

I like to save this in the conf.d folder of nginx, it works for me and i never run into issues.

Expand All @@ -181,11 +191,13 @@ nano /etc/nginx/conf.d

This will bring an editor up, in which you will paste

### Client Proxy Config

```
server {
listen 80;
listen [::]:80;
server_name support.example.com;
server_name peppermint.example.com;
add_header Strict-Transport-Security "max-age=15552000; includeSubDomains" always;
location / {
Expand All @@ -205,7 +217,36 @@ server {
Replace the server name with your url of choice, including subdomain and procced to save the file as

```
peppermint.conf
peppermint-client.conf
```

### API Proxy Config

```
server {
listen 80;
listen [::]:80;
server_name peppermintapi.example.com;
add_header Strict-Transport-Security "max-age=15552000; includeSubDomains" always;
location / {
proxy_pass http://127.0.0.1:5003;
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forward-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
proxy_redirect off;
proxy_read_timeout 5m;
}
client_max_body_size 10M;
}
```

Replace the server name with your url of choice, including subdomain and procced to save the file as, make sure this matches what you put in the docker-compose.yml file

```
peppermint-api.conf
```

### Restarting nginx
Expand All @@ -221,3 +262,7 @@ systemctl restart nginx
You should now be able to see peppermint running on your choosen subdomain.

I hope you found this guide usual :)

## Issues i discovered

An issue i discovered was that the api was not able to serve requests if it wasnt HTTPS, just bear that in mind.
Binary file added apps/docs/public/favicon.ico
Binary file not shown.
8 changes: 4 additions & 4 deletions apps/site/pages/_app.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import '@/styles/globals.css'
import type { AppProps } from 'next/app'
import "@/styles/globals.css";
import type { AppProps } from "next/app";

export default function App({ Component, pageProps }: AppProps) {
return <Component {...pageProps} />
}
//@ts-expect-error
return <Component {...pageProps} />;
8 changes: 6 additions & 2 deletions apps/site/pages/_document.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { Html, Head, Main, NextScript } from 'next/document'
//@ts-nocheck
import { Head, Html, Main, NextScript } from "next/document";


export default function Document() {
return (
Expand All @@ -9,5 +11,7 @@ export default function Document() {
<NextScript />
</body>
</Html>
)
);


}
5 changes: 3 additions & 2 deletions apps/site/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@ export default function Home() {
Aiming to bridge the gap of features and cost.
</p>
<div className="flex space-x-6">
{footer.social.map((item) => (
{/* {footer.social.map((item) => (
<a
key={item.name}
href={item.href}
Expand All @@ -661,7 +661,8 @@ export default function Home() {
<span className="sr-only">{item.name}</span>
<item.icon className="h-6 w-6" aria-hidden="true" />
</a>
))}
))} */}

</div>
</div>
<div className="mt-16 grid grid-cols-2 gap-8 xl:col-span-2 xl:mt-0">
Expand Down
Loading

0 comments on commit ef6faff

Please sign in to comment.