Exposing external JSON API in an Nginx custom path?

Moorage moorage at protonmail.ch
Sun Nov 11 20:50:14 UTC 2018


Hi,

> So you want the request to nginx of "/mesh/" to become a request to your
> upstream server of "/"?

Initially, that was the idea.  For no reason OTHER than out of the box, the upstream UI *is*, by default, available at

  http://mesh.example.com:8080/

> It can be done; however, I suggest that you will find things easier
> to reverse-proxy if you can configure the mesh server to expect that
> its root is /mesh/, so that it exposes its api at /mesh/api/v1 and it
> redirects to /mesh/mesh-ui/

In the mesh ui config, there IS this

   config/mesh-ui-config.js

	(function(window, document) {

	    /**
	     * Settings which can be configured per app instance, without requiring the app be re-built from
	     * source.
	     */
	    var meshUiConfig = {
	        // The URL to the Mesh API
	        apiUrl: '/api/v1/',

	        // The ISO-639-1 code of the default language
	...


So I *can* change

-	        apiUrl: '/api/v1/',
+	        apiUrl: '/mesh/api/v1/',

which I have tried -- but it didn't end up working for me.  Probably because of everything _else_ wrong so far.

>
> >       location ~ /mesh/ {
> >
>
> "~" is not "starts with". You probably want "^~" there instead.
>
> >       	proxy_pass http://meshproxy;
> >
>
> If you want the request to upstream to be "/mesh/", use that. Otherwise, use
>
> proxy_pass http://meshproxy/;
>
> >       	proxy_redirect off;
> >
>
> You probably do not want that. Perhaps "proxy_redirect default;"; perhaps
> something else based on whatever the mesh service actually returns. From
> your example, you may want
>
> proxy_pass / /mesh/;

Some more 'stuff' to try!

Let's see how it works ...

Cheers.


More information about the nginx mailing list