Skip to content

Commit

Permalink
Merge pull request #275 from SELab-2/feature/nginx_routes
Browse files Browse the repository at this point in the history
app.conf changes
  • Loading branch information
AWerbrouck authored May 20, 2024
2 parents 1801b0d + 31b9290 commit e88b6f6
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 29 deletions.
1 change: 1 addition & 0 deletions backend/web-bff/App/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ if (DEVELOPMENT) {
} else {
// When using production mode, please make sure a mongodb instance is running and accepting connections
// on port PORT. Also make sure the user exists.
app.set('trust proxy', 1)
app.use(session({
name: 'pigeon session',
secret: process.env.EXPRESS_SESSION_SECRET,
Expand Down
88 changes: 59 additions & 29 deletions nginx/conf/app.conf
Original file line number Diff line number Diff line change
@@ -1,38 +1,68 @@
server {
listen 80;
listen [::]:80;
http {
map $request_method $index_req {
POST "index_post";
default "default_index"; # A default value to prevent errors.
}

upstream express_server {
server localhost:3000;
}



server {
listen 80;
listen [::]:80;

server_name sel2-6.ugent.be www.sel2-6.ugent.be;
server_tokens off;
server_name sel2-6.ugent.be www.sel2-6.ugent.be;
server_tokens off;

location /.well-known/acme-challenge/ {
location /.well-known/acme-challenge/ {
root /var/www/certbot;
}
}

location / {
return 301 https://sel2-6.ugent.be$request_uri;
}
}
location / {
return 301 https://sel2-6.ugent.be$request_uri;
}
}

server {
listen 443 default_server ssl http2;
listen [::]:443 ssl http2;
server {
listen 443 default_server ssl http2;
listen [::]:443 ssl http2;

server_name sel2-6.ugent.be;
server_name sel2-6.ugent.be;

ssl_certificate /etc/nginx/ssl/live/sel2-6.ugent.be/fullchain.pem;
ssl_certificate_key /etc/nginx/ssl/live/sel2-6.ugent.be/privkey.pem;
ssl_certificate /etc/nginx/ssl/live/sel2-6.ugent.be/fullchain.pem;
ssl_certificate_key /etc/nginx/ssl/live/sel2-6.ugent.be/privkey.pem;

location /api/ {
proxy_pass http://spring_container:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Authorization $http_authorization;
}
location / {
root /usr/share/nginx/html/build;
try_files $uri $uri/ /index.html;
}
location /api/ {
proxy_pass http://spring_container:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Authorization $http_authorization;
break;
}

location /web/ {
proxy_pass http://express_server;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
break;
}

location / {

if ($index_req = "index_post") {
proxy_pass http://express_server;
break;
}

root /usr/share/nginx/html/build;
try_files $uri $uri/ /index.html;
}
}
}

0 comments on commit e88b6f6

Please sign in to comment.