WebSocket Connection Without an Extra Port

  • Last update:April 24, 2026
  • Overview

    Version

    Report Server Version

    10.0

    Application Scenario

    Some companies enforce strict security policies on project environments and restrict which ports can be opened.

    WebSocket connections often fail when only one port is opened.

    Function Description

    When additional WebSocket ports cannot be opened, WebSocket traffic can be forwarded to an existing open port.

    This document describes how WebSocket connections can still work when only one port (8888) is opened in an environment consisting of Linux, nginx, and Tomcat.

    iconNote: 

    Starting from the FineReport project of V11.0.2 and later versions, a container-native WebSocket solution has been added. You are advised to first check if the container-native WebSocket solution can be used.

    No user operation, manual configuration, or additional port is required. The system automatically uses the WebSocket implementation built into the web container for connection, and the WebSocket connection reuses the HTTP port.

    Example

    Setting WebSocket Forwarding Port

    Log in to the decision-making platform as the admin, choose System Management > System Setting > General, and set WebSokcet Request Port, as shown in the following figure. /

    The port set in this section (port 8888 in this example) is the only external port of the project. You can set it as needed.

    iconNote: 

    1. In a cluster environment, Proxy Server Configured is automatically ticked by default. In a non-cluster environment, tick it manually. (The option indicates that nginx is already configured.)

    2. If WebSocket Setting shown in the following figure is not displayed under System Management > System Setting > General on the decision-making platform, the WebSocket connection is already properly configured, requiring no further modification.

    Modifying nginx.conf

    In the server block in nginx.conf where nginx listens on port 8888, add a branch that matches request URLs starting with /socket.io/ and forwards requests to upstream servers. For details, see the following configurations.

    ...
    server {
            listen 8888;#Listening port. It should be consistent with the port configured in WebSocketConfig.requestPort.
            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;
            }
            #Requests URLs starting with /socket.io/ are matched and forwarded to upstream servers.
            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

    The configuration will take effect after you restart nginx and the FineReport project.

    In this way, you can open only port 8888 for the report project and WebSocket connections to work normally. 

    Attachment List


    Theme: Decision-making Platform
    • 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