Skip to main content
1-Visitor
May 26, 2016
Question

How to set up a reverse proxy with organization structure?

I am trying to put in place nginx as a reverse proxy to hide the thingworx's URLs.

I use this configuration for nginx:

    server {

        listen       80;

        server_name  localhost;


          location /MyApp {

               proxy_pass http://localhost:8080/Thingworx/FormLogin/MyAppOrg;

               proxy_set_header Host $host;

               proxy_set_header X-Real-IP $remote_addr;

          }

     }

It works fine for the login page of the organization but the Home Mashup cannot be displayed, I got an 404 error.

To solve it, I need to add this rule:

          location /Thingworx {

               proxy_pass http://localhost:8080/Thingworx;

               proxy_set_header Host $host;

               proxy_set_header X-Real-IP $remote_addr;

          }

But by doing this I didn't mask anything, I can see the full internal url in the address bar after logging...

Does anyone know how to setup a reverse proxy with organizations ?

8 replies

5-Regular Member
May 26, 2016

Fabien, can you post your .conf file? With your location set as /Thingworx, all the proxy_pass flag would need is host:port.

Translate
fserre1-VisitorAuthor
1-Visitor
May 26, 2016

Thanks AAnjan for your answer. I've modified the .conf file as followed:

worker_processes  1;

events {

    worker_connections  1024;

}

http {

    include       mime.types;

    default_type  application/octet-stream;

    sendfile        on;

    keepalive_timeout  65;

    server {

        listen       80;

        server_name  localhost;

        location /Thingworx {

               proxy_pass http://localhost:8080;

               proxy_set_header Host $host;

               proxy_set_header X-Real-IP $remote_addr;

          }         

          location /MyApp {

               proxy_pass http://localhost:8080/Thingworx/FormLogin/MyAppOrg;

               proxy_set_header Host $host;

               proxy_set_header X-Real-IP $remote_addr;

          }

     }

}

But once logged, I am still redirected to : http://192.168.73.128/Thingworx/Runtime/index.html#master=MyAppMain&mashup=WelcomeScreen

Translate
5-Regular Member
May 26, 2016

Since you have the location for /Thingworx, can you remove the /MyApp one and retry? So that your server section would just have location /Thingworx.

Here's an example configuration I've used before:

server {

    listen      80;

    server_name  localhost;

        location /Thingworx/WS {

            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

            proxy_pass http://thingworx_server;

            proxy_http_version 1.1;

            proxy_set_header Upgrade $http_upgrade;

            proxy_set_header Connection "upgrade";

            include /etc/nginx/conf.d/acl.default;

            allow a specific ip;

            allow 127.0.0.1;

            deny all;

        }

        location / {

            add_header Access-Control-Allow-Origin *;

            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

            proxy_pass http://thingworx_server;

            proxy_http_version 1.1;

            include /etc/nginx/conf.d/acl.default;

            allow a specific ip;

            allow 127.0.0.1;

            deny all;

        }

I've added the upgrade headers to allow EMS websocket connections as well. My setting was was specific to allow any connection that would hit /Thingworx/WS (primarily used for Edge connectivity).

Translate