URL jumps between different visualizations behind a reverse proxy

kevinrn
2023-02-01
2024-07-26
  • kevinrn - 2023-02-01

    Hi community,

    I want to open different visualizations from multiple CODESYS webservers using a reverse-proxy. Each visualization should work with the webserver's primary IP-address and a location path of the proxy. The visualization includes URL jumps to other CODESYS webservers that are accessible in the same local network. This requires replacing the content site's URL when it's opened through the proxy, as it's not possible to change the URL addresses in the PLC program.

    Description and Overview

    I have a fully functioning Nginx configuration that allows accessing the webvisu from the controllers through a reverse-proxy.

    Image overview:
    Overview.png

    Devices:
    DDC1 with webvisu: 192.168.20.86 (Webserver port: 80)
    DDC2 with webvisu: 192.168.20.87 (Webserver port: 80)
    nginx reverse proxy server: 192.168.20.205 (nginx port: 4000)

    nginx reverse proxy configuration:

      server {
        listen 4000 default_server;
    
        location /visu1  {
          rewrite ^/WebVisuV3.bin$ /visu1/WebVisuV3.bin last;
          rewrite ^(/visu1)$ $1/;
          rewrite ^/visu1(.+) $1 break;
    
          sub_filter 'http://192.168.20.86'  'http://localhost:4000/visu1';
          sub_filter 'http://192.168.20.87'  'http://localhost:4000/visu2';
    
          sub_filter '"/' '"/visu1/';
          sub_filter_types *;
          sub_filter_once on;
    
          proxy_set_header Accept-Encoding "";
          proxy_set_header Host $http_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;
    
          proxy_pass http://192.168.20.86$1$is_args$args;
          proxy_http_version 1.1;
        }
    
        location /visu2 {
          rewrite ^/WebVisuV3.bin$ /visu2/WebVisuV3.bin last;
          rewrite ^(/visu2)$ $1/;
          rewrite ^/visu2(.+) $1 break;
    
          sub_filter 'http://192.168.20.86'  'http://localhost:4000/visu1';
          sub_filter 'http://192.168.20.87'  'http://localhost:4000/visu2';
    
          sub_filter '"/' '"/visu2/';
          sub_filter_types *;
          sub_filter_once on;
    
          proxy_set_header Accept-Encoding "";
          proxy_set_header Host $http_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;
    
          proxy_pass http://192.168.20.87$1$is_args$args;
          proxy_http_version 1.1;
        }
      }
    

    This configuration works as expected and I can open the visualizations through the proxy-server.

    visu1: http://192.168.20.205:4000/visu1
    visu2: http://192.168.20.205:4000/visu2

    Problem:

    The visualizations have url jumps that direct to other webservers. For example: On the webserver visu1, there is a button with an URL jump to the url of visu2.

    Such behaviour is normal, and it can be solved by using sub_filter for nginx.
    So, I configured the sub_filter and I see from the client site, that the origin url is replaced.

    But I'm afraid that the WebVisuV3.bin is doing some checks with the program code before the jump is executed. From my point of understanding it checks the size of the given URL string or something, because I get following error:
    Actual packet size 936 smaller than expected 940.
    If I change the string to something else or add some whitespaces, it shows that the size does change.
    I attached a gif which shows this:

    size-change.gif

    Questions

    • Is there a way to find out more about the function and behavior of "webVisuV3.bin"?
    • Does anyone have any ideas on how to proceed to solve the problem?

    Thank you in advance,
    cheers
    Kevin

     
  • squale - 2024-07-26

    Hi kevinrn,
    I have the same question as yours.
    On my side I try to make nginx work but it doesn't goes well. I think the sub_filter doesn't work int this case.

     

Log in to post a comment.