Using WebSocket Without Opening a Dedicated Port

  • Last update:September 09, 2025
  • Overview

    Version

    FineBI Server Version

    6.0

    Application Scenario

    Some companies enforce strict security policies for project environments, which impose many restrictions on port opening.

    If only one port is open, WebSocket connections often fail to be established.

    Function Description

    When opening the WebSocket port is not feasible, you can forward WebSocket traffic through an existing open port.

    This document briefly introduces how to use WebSocket normally with only one open port 8888 in an environment consisting of Linux, Nginx, and Tomcat.

    iconNote:

    FineBI provides a built-in containerized WebSocket solution. You are advised to check whether you can use the solution first.

    The system can automatically establish WebSocket connections using the web container's built-in WebSocket and reuse existing HTTP ports, requiring no user operation, manual configuration, or additional port opening.

    Example

    Setting the WebSocket Forwarding Port

    Log in to the FineBI system as the admin, choose System Management > System Setting > General, and set WebSocket Request Port, as shown in the following figure.

    Set Port in WebSocket Request Port to the only open port of the project. This document takes port 8888 as an example.

    iconNote:

    1. In a cluster environment, Proxy Server Configured is selected by default, while in a non-cluster environment, you need to manually select Proxy Server Configured (indicating that you have configured Nginx).

    2. FineBI provides a built-in containerized WebSocket solution to help you quickly configure the WebSocket port.

    If the General page under System Management > System Setting does not display the WebSocket Setting setting item, it means that the WebSocket connection has been correctly configured and no modification is required.

    1.png

    Modifying the nginx.conf File

    In the server block of the Nginx configuration file nginx.conf, add a routing rule to handle requests whose URL includes /socket.io/, and forward WebSocket traffic to the specified open port 8888. The detailed configuration is as follows:

    ...
    server {
            listen 8888;#This is the port to be listened by Nginx. Ensure that the port is consistent with that set in WebSocket Request Port under System Management > System Setting > General > WebSocket Setting.
            server_name _;
            underscores_in_headers on;
            location / {
                proxy_http_version 1.1;
                proxy_pass http://FR.com;
                proxy_next_upstream http_500 http_502 http_503 http_504 error timeout invalid_header non_idempotent;
                proxy_redirect off;
                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 Connection "";
                #proxy_set_header X-Forwarded-Proto "https";
                proxy_connect_timeout 20;
                proxy_read_timeout 1000;
                proxy_send_timeout 300;
            }
            # This part is used to identify requests starting with /socket.io/ and proxy them to the WebSocket upstream server.
            location ^~ /socket.io/ {
                proxy_pass http://WBS.com;
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "upgrade";
                proxy_connect_timeout 20;
                proxy_read_timeout 1000;
                proxy_send_timeout 300;
            }
            ...
    }
    ...

    Restarting the Service

    Restart Nginx and the FineBI project. The configuration will take effect.

    You just need to open the 8888 port to use the FineBI project and WebSocket normally.

    附件列表


    主题: System Management
    • Helpful
    • Not helpful
    • Only read

    滑鼠選中內容,快速回饋問題

    滑鼠選中存在疑惑的內容,即可快速回饋問題,我們將會跟進處理。

    不再提示

    10s後關閉

    Get
    Help
    Online Support
    Professional technical support is provided to quickly help you solve problems.
    Online support is available from 9:00-12:00 and 13:30-17:30 on weekdays.
    Page Feedback
    You can provide suggestions and feedback for the current web page.
    Pre-Sales Consultation
    Business Consultation
    Business: international@fanruan.com
    Support: support@fanruan.com
    Page Feedback
    *Problem Type
    Cannot be empty
    Problem Description
    0/1000
    Cannot be empty

    Submitted successfully

    Network busy