Set bind url
Description
I've looked just about everywhere I can think and can't find if there is an option for this. Having followed the install steps here: https://theia-ide.org/docs/composing_applications/ I am running Theia behind a reverse proxy (nginx), but alongside other apps. I would ideally like to access it at localhost/theia (as opposed to the root of localhost), but I can find no way to specify the bind point. nginx is correctly forwarding requests on localhost/theia to localhost:3000, but I receive a "Cannot GET" error.
Is this possible?
@cjchristopher I am not sure whether anybody manages it. Express.js has middleware, maybe there is a way to specify the root path.
Right. Seems related to https://github.com/eclipse-theia/theia/issues/6844 as well.
I'm digging around Theia and can't see an obvious place to set this for Express - could any contributor point me in the right direction?
I've searched also right now and could not find anything. It seems that Express.js does not allow to change the base path vis the middleware. I wonder what would be the minimal change to allow alternative base path in Theia backend application.
Alternatively we state that it is not supported and one can use a proxy always.
I did find some evidence that you can set the base path in Express, I just couldn't locate where in the Theia codebase I would add that call. Although potentially I am misunderstanding your explicit meaning when you say "via the middleware"
See: https://stackoverflow.com/questions/42902739/express-app-change-base-url and https://stackoverflow.com/a/5994334
In Theia you will need to implement BackendApplicationContribution with the custom extension. There is configure lifecycle hook to configure the express application.
@cjchristopher I ran into the same problem I think. When you look at the GET request, is it sending the get request to the expected url? For example localhost:3000/index.js? I ran into an issue where it would pass the path wrong and I had to add a rewrite rule in order to pass the correct URL.
Maybe try adding rewrite ^/theia/(.*) /$1 break; to your location block.
Is there anything new?
@cjchristopher I ran into the same problem I think. When you look at the GET request, is it sending the get request to the expected url? For example
localhost:3000/index.js? I ran into an issue where it would pass the path wrong and I had to add a rewrite rule in order to pass the correct URL.Maybe try adding
rewrite ^/theia/(.*) /$1 break;to your location block.
This worked for me. My nginx config:
server {
listen 443 ssl;
...
rewrite ^/theia/(.*) /$1 break;
location / {
proxy_pass http://host.docker.internal:3000; // I was using docker in mac, so added `http://host.docker.internal`, you can use `http://localhost` for your case.
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
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;
}
}