feat: enable API_URL in Dockerfile

fix tranga.conf not redirecting /api/ requests
This commit is contained in:
= 2024-03-07 12:16:19 +11:00
parent d33ac16c7d
commit 5af3005179
3 changed files with 30 additions and 52 deletions

View File

@ -2,4 +2,5 @@
COPY ./Website /usr/share/nginx/html
COPY ./nginx /etc/nginx
EXPOSE 80
ENV API_URL=http://tranga-api:6531
CMD ["nginx", "-g", "daemon off;"]

View File

@ -1,52 +0,0 @@
server {
listen 80;
listen [::]:80;
server_name localhost;
#access_log /var/log/nginx/host.access.log main;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
location ~ /api/ {
proxy_pass_request_headers on;
set $upstream_app tranga-api;
set $upstream_port 6531;
set $upstream_proto http;
proxy_pass $upstream_proto://$upstream_app:$upstream_port;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}

View File

@ -0,0 +1,29 @@
server {
listen 80 default_server;
listen [::]:80 default_server;
http2 on;
server_name _;
access_log /dev/stdout main;
error_log /dev/stderr;
location /api/ {
proxy_pass_request_headers on;
rewrite ^/api/(.*)$ /$1 break;
proxy_pass $API_URL;
}
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}