Skip to content

Commit

Permalink
Setup nginx
Browse files Browse the repository at this point in the history
  • Loading branch information
sdepold committed Sep 10, 2023
1 parent 957554c commit 146aa04
Show file tree
Hide file tree
Showing 4 changed files with 113 additions and 0 deletions.
42 changes: 42 additions & 0 deletions ops/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
version: "3.9"
services:
website:
image: ghcr.io/sdepold/feedr-web:1.12.0
restart: always
deploy:
resources:
limits:
cpus: "0.5"
memory: 512M
reservations:
cpus: "0.5"
memory: 512M
api:
image: ghcr.io/sdepold/feedr-api:1.12.0
restart: always
deploy:
resources:
limits:
cpus: "1.5"
memory: 1024M
reservations:
cpus: "1.5"
memory: 1024M

nginx:
container_name: nginx
image: nginx:latest
ports:
- "80:80"
volumes:
- ./nginx:/etc/nginx/conf.d
restart: always
deploy:
resources:
limits:
memory: 256M
reservations:
memory: 256M
depends_on:
- api
- website
33 changes: 33 additions & 0 deletions ops/nginx/feedr.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
server {
listen 80 default_server;
listen [::]:80 default_server;

server_name feedrapp.info;

access_log /var/log/nginx/feedr-access.log;
error_log /var/log/nginx/feedr-error.log error;

location /api {
proxy_pass http://api:4000;
proxy_http_version 1.1;

proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
}

location / {
if ($arg_q) {
rewrite ^ /api/ permanent;
}

proxy_pass http://website:3000;
proxy_http_version 1.1;

proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
}
}
3 changes: 3 additions & 0 deletions ops/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

docker compose -f ops/docker-compose.yml up -d
35 changes: 35 additions & 0 deletions ops/test-local.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
if curl -Ls "http://localhost" | grep -q "Introduction"; then
echo "Feedr Website: Works"
else
echo "Feedr Website: Unavailable"
fi

if curl -Ls "http://localhost/hosting" | grep -q "Hosting"; then
echo "Feedr Website (Hosting): Works"
else
echo "Feedr Website (Hosting): Unavailable"
fi

if curl -Ls "http://localhost/?q=https://bitte.kaufen/magazin/feed/" | grep -q "bitte.kaufen Magazin für Eltern"; then
echo "Feedr API (forwarding): Works"
else
echo "Feedr API (forwarding): Unavailable"
fi

if curl -Ls "http://localhost/api/?q=https://bitte.kaufen/magazin/feed/" | grep -q "bitte.kaufen Magazin für Eltern"; then
echo "Feedr API: Works"
else
echo "Feedr API: Unavailable"
fi

if curl -Ls "http://localhost/api?q=https://bitte.kaufen/magazin/feed/" | grep -q "bitte.kaufen Magazin für Eltern"; then
echo "Feedr API (no trailing slash): Works"
else
echo "Feedr API (no trailing slash): Unavailable"
fi

if curl -Ls "http://localhost/api?callback=foo&q=https://bitte.kaufen/magazin/feed/" | grep -q 'foo({"responseStatus":200'; then
echo "Feedr API (callback): Works"
else
echo "Feedr API (callback): Unavailable"
fi

0 comments on commit 146aa04

Please sign in to comment.