Skip to content

Commit

Permalink
Merge pull request #94 from SELab-2/dev_env
Browse files Browse the repository at this point in the history
chore: /api
  • Loading branch information
Topvennie authored Mar 11, 2024
2 parents 5ae1e62 + 0d7e100 commit 15ec0c4
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 28 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ This application was developed within the framework of the course "Software Engi
Run `development.sh`.
It starts the development environment and attaches itself to the output of the backend.
The backend will auto reload when changing a file.
Acces the server by going to `https://localhost:8080` for the backend and `https://localhost:443` for the frontend.
Acces the server by going to `https://localhost/api` for the backend and `https://localhost` for the frontend.

If you change something to one of the docker files run `docker-compose -f development.yml up --build` to rebuild.

Expand Down
6 changes: 3 additions & 3 deletions backend/ypovoli/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
https://docs.djangoproject.com/en/5.0/ref/settings/
"""

import os
from datetime import timedelta
from os import environ
from pathlib import Path
import os

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
Expand Down Expand Up @@ -89,8 +89,8 @@
# Application endpoints

CAS_ENDPOINT = "https://login.ugent.be"
CAS_RESPONSE = "https://localhost:8080/auth/cas/echo"
API_ENDPOINT = "https://localhost:8080"
CAS_RESPONSE = "https://localhost:8080/api/auth/cas/echo"
API_ENDPOINT = "https://localhost:8080/api"

# Database
# https://docs.djangoproject.com/en/5.0/ref/settings/#databases
Expand Down
39 changes: 26 additions & 13 deletions backend/ypovoli/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,31 @@


urlpatterns = [
# Base API endpoints.
path("", include("api.urls")),
# Authentication endpoints.
path("auth/", include("authentication.urls")),
path("notifications/", include("notifications.urls"), name="notifications"),
# Swagger documentation.
path(
"swagger/",
schema_view.with_ui("swagger", cache_timeout=0),
name="schema-swagger-ui",
),
path(
"swagger<format>/", schema_view.without_ui(cache_timeout=0), name="schema-json"
),
"api/",
include(
[
# Base API endpoints.
path("", include("api.urls")),
# Authentication endpoints.
path("auth/", include("authentication.urls")),
path(
"notifications/",
include("notifications.urls"),
name="notifications",
),
# Swagger documentation.
path(
"swagger/",
schema_view.with_ui("swagger", cache_timeout=0),
name="schema-swagger-ui",
),
path(
"swagger<format>/",
schema_view.without_ui(cache_timeout=0),
name="schema-json",
),
]
),
)
]
25 changes: 15 additions & 10 deletions data/nginx/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -21,32 +21,37 @@ http {
}

server {
listen 443 ssl;
listen [::]:443 ssl;
listen 8080 ssl;
listen [::]:8080 ssl;

ssl_certificate ssl/certificate.crt;
ssl_certificate_key ssl/private.key;

location / {
proxy_pass http://frontend;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_redirect off;
return 301 https://$host$request_uri;
}
}

server {
listen 8080 ssl;
listen [::]:8080 ssl;
listen 443 ssl;
listen [::]:443 ssl;

ssl_certificate ssl/certificate.crt;
ssl_certificate_key ssl/private.key;

location /api/ {
proxy_pass https://backend$request_uri;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_redirect off;
}


location / {
proxy_pass https://backend;
proxy_pass http://frontend;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_redirect off;
}
}
}
}
2 changes: 1 addition & 1 deletion development.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ services:
build:
context: $BACKEND_DIR
dockerfile: Dockerfile
command: bash -c "./setup.sh && python manage.py runsslserver 192.168.90.2:8080"
command: /bin/bash -c "./setup.sh && python manage.py runsslserver 192.168.90.2:8080"
expose:
- 8000
volumes:
Expand Down

0 comments on commit 15ec0c4

Please sign in to comment.