For some very specific reasons I have to access two different routes on my frontend and the only variable in how they are accessed I have control over is the port. So what I would like to do is depending on the port, either access the frontent normally, or access it under a different path:
myUrl:80 -> myUrl:80
myUrl:8081 -> myUrl:80/someRoute
I have tried to implement this with a proxy_pass as follows:
# Standard frontend server
server {
listen 80 default_server;
server_name _;
root /usr/share/nginx/html;
index index.html;
error_page 500 502 503 504 /50x.html;
location / {
try_files $uri $uri/ /index.html
add_header Cache-Control "no-cache";
}
location /static {
expires 1y;
add_header Cache-Control "public";
}
}
# Proxy $url:8081 -> url:80/somePath/
server {
listen 8081 default_server;
server_name _;
location / {
proxy_set_header Host $host;
proxy_set_header X-Original-Host $http_host;
proxy_set_header X-Original-Scheme $scheme;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_pass http://127.0.0.1:80/somePath/;
}
}
This then throws an error in the frontend console:
The script has an unsupported MIME type ('text/html').
In case it's relevant, I'm using Flutter Web
.