You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Sebastian Trueg <tr...@truegeex.de> on 2020/07/22 08:43:51 UTC

Fuseki behind a reverse proxy with sub-path

Hello everyone,

this might be an old or even simple question (I actually hope it is) but
I was not able to find an answer thus far:

Can I run the Fuseki admin UI behind a reverse proxy with a sub-path?

In my case I have one reverse proxy which routes a path like
  /admin/fuseki
to the Fuseki admin ui.

The problem is that css and the like are not loaded properly due to a
missing trailing slash on the base path. But adding the slash to the
route will result in a 404...

Maybe someone had this problem before or it is super-obvious to someone.

Thanks in advance.

Regards,
Sebastian

Re: Fuseki behind a reverse proxy with sub-path

Posted by Andy Seaborne <an...@apache.org>.
Some URL are generated in JS in the

But the CSS is done plain linking and relative URLs: 
href="css/bootstrap.min.css" but Fuseki specific code.

inline below:

On 23/07/2020 15:13, Sebastian Trueg wrote:
> I actually mixed it up in my last email. I get the 404 if I route to
> 
> http://pdm-portal-triple-store.portal-dev:3030
> 
> instead of
> 
> http://pdm-portal-triple-store.portal-dev:3030/
> 
> Regarding the deployment: no service mesh.
> The service looks like this:
> 
> apiVersion: v1
> kind: Service
> metadata:
>    name: pdm-portal-triple-store
> spec:
>    ports:
>    - name: web
>      port: 3030
>      protocol: TCP
>      targetPort: 3030
>    selector:
>      app: pdm-portal-triple-store
>    sessionAffinity: None
>    type: ClusterIP
> 
> and I have one Ingress to my nginx:
> 
> apiVersion: networking.k8s.io/v1beta1
> kind: Ingress
> metadata:
>    name: pdm-dev
> spec:
>    rules:
>    - host: pdm-dev.10.1.101.78.nip.io
>      http:
>        paths:
>        - backend:
>            serviceName: pdm-portal-router
>            servicePort: 8080
> 
> The nginx config is a bit too big to post IMHO but the interesting bit is:
> 
> location /admin/triplestore {
>     proxy_pass http://pdm-portal-triple-store.portal-dev:3030/;
> }

Thought:

Should that be

location /admin/triplestore/

with trailing /

because resolving "css/foobar" against /admin/triplestore is 
/admin/css/foobar.

Resolution has to know the /admin/triplestore/ is a parth to a directory.

/admin/triplestore looks like a file and relative URLs get resolved to 
be siblings of files.

> Now this gets me to the main page, but without any css since the
> relative paths are looked up at
> 
> http://pdm-dev.10.1.101.78.nip.io/admin/css/bootstrap.min.css
> 
> etc.
> 
> I solved this issue in my own spring.boot services using a
> X-Forwarded-Prefix header.
> 
> Regards,
> Sebastian
> 
> 
> On 23.07.20 15:52, Rob Vesse wrote:
>> Sebastian
>>
>> Is this using Istio or some other service mesh?
>>
>> Could you show your VirtualService (or equivalent) definition? (YAML preferable for readability)
>>
>> This may well be an actual Fuseki bug with the JS, I know we have some production JS UIs where we explicitly have to set the base path so that CSS, JS links etc come back correctly so that they work with the VirtualService routing.  It may require doing something similar for Fuseki.
>>
>> Rob
>>
>> On 23/07/2020, 14:45, "Sebastian Trueg" <tr...@truegeex.de> wrote:
>>
>>      Hi Andy,
>>
>>      thanks for looking into this.
>>
>>      On 22.07.20 18:07, Andy Seaborne wrote:
>>      >
>>      >
>>      > On 22/07/2020 09:43, Sebastian Trueg wrote:
>>      >> Hello everyone,
>>      >>
>>      >> this might be an old or even simple question (I actually hope it is) but
>>      >> I was not able to find an answer thus far:
>>      >>
>>      >> Can I run the Fuseki admin UI behind a reverse proxy with a sub-path?
>>      >
>>      > I haven't tried but it will be easier if the reverse proxy has the same
>>      > webapp name in the URL (which may not be what you want).
>>      >
>>      >> In my case I have one reverse proxy which routes a path like
>>      >>    /admin/fuseki
>>      >> to the Fuseki admin ui.
>>      >
>>      > to /$/... ?
>>
>>      I want to access index.html, dataset.html, manage.html, etc. via my
>>      nginx proxy (Kubernetes deployment) at
>>
>>      /admin/fuseki/index.html, /admin/fuseki/dataset.html, etc.
>>
>>      >
>>      >
>>      >> The problem is that css and the like are not loaded properly due to a
>>      >> missing trailing slash on the base path. But adding the slash to the
>>      >> route will result in a 404...
>>      >
>>      > It might be the CSS/HTML isn't general enough in link mangling.
>>      >
>>      > Do you have a concrete example?
>>      >
>>      > URL sent
>>
>>      http://pdm-dev.10.1.101.78.nip.io/admin/fuseki
>>
>>      > URL routed to
>>
>>      Kubernetes internal URL:
>>      http://pdm-portal-triple-store.portal-dev:3030
>>
>>      > Links in HTML back.
>>
>>      css links will look like
>>      http://pdm-dev.10.1.101.78.nip.io/admin/css/main.css
>>
>>      But adding a trailing slash to the url route liks so:
>>      http://pdm-portal-triple-store.portal-dev:3030/
>>
>>      will result in a 404
>>
>>
>>      >
>>      >     Andy
>>      >
>>      >
>>      >>
>>      >> Maybe someone had this problem before or it is super-obvious to someone.
>>      >>
>>      >> Thanks in advance.
>>      >>
>>      >> Regards,
>>      >> Sebastian
>>      >>
>>      >
>>
>>
>>
>>
>>
> 

Re: Fuseki behind a reverse proxy with sub-path

Posted by Sebastian Trueg <tr...@truegeex.de>.
I actually mixed it up in my last email. I get the 404 if I route to

http://pdm-portal-triple-store.portal-dev:3030

instead of

http://pdm-portal-triple-store.portal-dev:3030/

Regarding the deployment: no service mesh.
The service looks like this:

apiVersion: v1
kind: Service
metadata:
  name: pdm-portal-triple-store
spec:
  ports:
  - name: web
    port: 3030
    protocol: TCP
    targetPort: 3030
  selector:
    app: pdm-portal-triple-store
  sessionAffinity: None
  type: ClusterIP

and I have one Ingress to my nginx:

apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: pdm-dev
spec:
  rules:
  - host: pdm-dev.10.1.101.78.nip.io
    http:
      paths:
      - backend:
          serviceName: pdm-portal-router
          servicePort: 8080

The nginx config is a bit too big to post IMHO but the interesting bit is:

location /admin/triplestore {
   proxy_pass http://pdm-portal-triple-store.portal-dev:3030/;
}

Now this gets me to the main page, but without any css since the
relative paths are looked up at

http://pdm-dev.10.1.101.78.nip.io/admin/css/bootstrap.min.css

etc.

I solved this issue in my own spring.boot services using a
X-Forwarded-Prefix header.

Regards,
Sebastian


On 23.07.20 15:52, Rob Vesse wrote:
> Sebastian
> 
> Is this using Istio or some other service mesh?
> 
> Could you show your VirtualService (or equivalent) definition? (YAML preferable for readability)
> 
> This may well be an actual Fuseki bug with the JS, I know we have some production JS UIs where we explicitly have to set the base path so that CSS, JS links etc come back correctly so that they work with the VirtualService routing.  It may require doing something similar for Fuseki.
> 
> Rob
> 
> On 23/07/2020, 14:45, "Sebastian Trueg" <tr...@truegeex.de> wrote:
> 
>     Hi Andy,
> 
>     thanks for looking into this.
> 
>     On 22.07.20 18:07, Andy Seaborne wrote:
>     > 
>     > 
>     > On 22/07/2020 09:43, Sebastian Trueg wrote:
>     >> Hello everyone,
>     >>
>     >> this might be an old or even simple question (I actually hope it is) but
>     >> I was not able to find an answer thus far:
>     >>
>     >> Can I run the Fuseki admin UI behind a reverse proxy with a sub-path?
>     > 
>     > I haven't tried but it will be easier if the reverse proxy has the same
>     > webapp name in the URL (which may not be what you want).
>     > 
>     >> In my case I have one reverse proxy which routes a path like
>     >>    /admin/fuseki
>     >> to the Fuseki admin ui.
>     > 
>     > to /$/... ?
> 
>     I want to access index.html, dataset.html, manage.html, etc. via my
>     nginx proxy (Kubernetes deployment) at
> 
>     /admin/fuseki/index.html, /admin/fuseki/dataset.html, etc.
> 
>     > 
>     > 
>     >> The problem is that css and the like are not loaded properly due to a
>     >> missing trailing slash on the base path. But adding the slash to the
>     >> route will result in a 404...
>     > 
>     > It might be the CSS/HTML isn't general enough in link mangling.
>     > 
>     > Do you have a concrete example?
>     > 
>     > URL sent
> 
>     http://pdm-dev.10.1.101.78.nip.io/admin/fuseki
> 
>     > URL routed to
> 
>     Kubernetes internal URL:
>     http://pdm-portal-triple-store.portal-dev:3030
> 
>     > Links in HTML back.
> 
>     css links will look like
>     http://pdm-dev.10.1.101.78.nip.io/admin/css/main.css
> 
>     But adding a trailing slash to the url route liks so:
>     http://pdm-portal-triple-store.portal-dev:3030/
> 
>     will result in a 404
> 
> 
>     > 
>     >     Andy
>     > 
>     > 
>     >>
>     >> Maybe someone had this problem before or it is super-obvious to someone.
>     >>
>     >> Thanks in advance.
>     >>
>     >> Regards,
>     >> Sebastian
>     >>
>     > 
> 
> 
> 
> 
> 

-- 
Sebastian Trueg
Managing Director
TrueGeeX UG (haftungsbeschränkt)
trueg@truegeex.de
http://www.linkedin.com/in/trueg
Mobile: 0049 1762 3244 664

Re: Fuseki behind a reverse proxy with sub-path

Posted by Rob Vesse <rv...@dotnetrdf.org>.
Sebastian

Is this using Istio or some other service mesh?

Could you show your VirtualService (or equivalent) definition? (YAML preferable for readability)

This may well be an actual Fuseki bug with the JS, I know we have some production JS UIs where we explicitly have to set the base path so that CSS, JS links etc come back correctly so that they work with the VirtualService routing.  It may require doing something similar for Fuseki.

Rob

On 23/07/2020, 14:45, "Sebastian Trueg" <tr...@truegeex.de> wrote:

    Hi Andy,

    thanks for looking into this.

    On 22.07.20 18:07, Andy Seaborne wrote:
    > 
    > 
    > On 22/07/2020 09:43, Sebastian Trueg wrote:
    >> Hello everyone,
    >>
    >> this might be an old or even simple question (I actually hope it is) but
    >> I was not able to find an answer thus far:
    >>
    >> Can I run the Fuseki admin UI behind a reverse proxy with a sub-path?
    > 
    > I haven't tried but it will be easier if the reverse proxy has the same
    > webapp name in the URL (which may not be what you want).
    > 
    >> In my case I have one reverse proxy which routes a path like
    >>    /admin/fuseki
    >> to the Fuseki admin ui.
    > 
    > to /$/... ?

    I want to access index.html, dataset.html, manage.html, etc. via my
    nginx proxy (Kubernetes deployment) at

    /admin/fuseki/index.html, /admin/fuseki/dataset.html, etc.

    > 
    > 
    >> The problem is that css and the like are not loaded properly due to a
    >> missing trailing slash on the base path. But adding the slash to the
    >> route will result in a 404...
    > 
    > It might be the CSS/HTML isn't general enough in link mangling.
    > 
    > Do you have a concrete example?
    > 
    > URL sent

    http://pdm-dev.10.1.101.78.nip.io/admin/fuseki

    > URL routed to

    Kubernetes internal URL:
    http://pdm-portal-triple-store.portal-dev:3030

    > Links in HTML back.

    css links will look like
    http://pdm-dev.10.1.101.78.nip.io/admin/css/main.css

    But adding a trailing slash to the url route liks so:
    http://pdm-portal-triple-store.portal-dev:3030/

    will result in a 404


    > 
    >     Andy
    > 
    > 
    >>
    >> Maybe someone had this problem before or it is super-obvious to someone.
    >>
    >> Thanks in advance.
    >>
    >> Regards,
    >> Sebastian
    >>
    > 






Re: Fuseki behind a reverse proxy with sub-path

Posted by Sebastian Trueg <tr...@truegeex.de>.
Hi Andy,

thanks for looking into this.

On 22.07.20 18:07, Andy Seaborne wrote:
> 
> 
> On 22/07/2020 09:43, Sebastian Trueg wrote:
>> Hello everyone,
>>
>> this might be an old or even simple question (I actually hope it is) but
>> I was not able to find an answer thus far:
>>
>> Can I run the Fuseki admin UI behind a reverse proxy with a sub-path?
> 
> I haven't tried but it will be easier if the reverse proxy has the same
> webapp name in the URL (which may not be what you want).
> 
>> In my case I have one reverse proxy which routes a path like
>>    /admin/fuseki
>> to the Fuseki admin ui.
> 
> to /$/... ?

I want to access index.html, dataset.html, manage.html, etc. via my
nginx proxy (Kubernetes deployment) at

/admin/fuseki/index.html, /admin/fuseki/dataset.html, etc.

> 
> 
>> The problem is that css and the like are not loaded properly due to a
>> missing trailing slash on the base path. But adding the slash to the
>> route will result in a 404...
> 
> It might be the CSS/HTML isn't general enough in link mangling.
> 
> Do you have a concrete example?
> 
> URL sent

http://pdm-dev.10.1.101.78.nip.io/admin/fuseki

> URL routed to

Kubernetes internal URL:
http://pdm-portal-triple-store.portal-dev:3030

> Links in HTML back.

css links will look like
http://pdm-dev.10.1.101.78.nip.io/admin/css/main.css

But adding a trailing slash to the url route liks so:
http://pdm-portal-triple-store.portal-dev:3030/

will result in a 404


> 
>     Andy
> 
> 
>>
>> Maybe someone had this problem before or it is super-obvious to someone.
>>
>> Thanks in advance.
>>
>> Regards,
>> Sebastian
>>
> 


Re: Fuseki behind a reverse proxy with sub-path

Posted by Andy Seaborne <an...@apache.org>.

On 22/07/2020 09:43, Sebastian Trueg wrote:
> Hello everyone,
> 
> this might be an old or even simple question (I actually hope it is) but
> I was not able to find an answer thus far:
> 
> Can I run the Fuseki admin UI behind a reverse proxy with a sub-path?

I haven't tried but it will be easier if the reverse proxy has the same 
webapp name in the URL (which may not be what you want).

> In my case I have one reverse proxy which routes a path like
>    /admin/fuseki
> to the Fuseki admin ui.

to /$/... ?


> The problem is that css and the like are not loaded properly due to a
> missing trailing slash on the base path. But adding the slash to the
> route will result in a 404...

It might be the CSS/HTML isn't general enough in link mangling.

Do you have a concrete example?

URL sent
URL routed to
Links in HTML back.

     Andy


> 
> Maybe someone had this problem before or it is super-obvious to someone.
> 
> Thanks in advance.
> 
> Regards,
> Sebastian
>