Project

General

Profile

Actions

Support #13719

open

How to configure reverse proxy for server push with fcgi

Added by Andrey Alekseev 7 days ago. Updated 7 days ago.

Status:
New
Priority:
Normal
Assignee:
-
Target version:
-
Start date:
05/02/2025
Due date:
% Done:

0%

Estimated time:

Description

I have a simple app that uses server push

#include <iostream>

#include <Wt/WServer.h>
#include <Wt/WResource.h>
#include <Wt/WText.h>
#include <Wt/WTime.h>
#include <Wt/WContainerWidget.h>

using namespace std;
using namespace Wt;


class WebHookResource : public WResource {
public:
    void handleRequest(const Http::Request &request, Http::Response &response) {
        WServer::instance()->postAll([&]{
            WApplication::instance()->root()
                ->addNew<WContainerWidget>()
                ->addNew<WText>( WTime::currentTime().toString() );
            WApplication::instance()->triggerUpdate();
        });
    }
};


#include <Wt/WEnvironment.h>
class Index : public WApplication {
public:
    Index(const WEnvironment& env)
        : WApplication{env}
    {
        root()->addNew<WText>("send a request to " + env.hostName() + env.getCgiValue("SCRIPT_NAME") + "/webhook");
        enableUpdates(true);
    }
};

int main(int argc, char** argv)
{
    int code = 0;
    try {
        WServer server(argc, argv, WTHTTP_CONFIGURATION);

        server.addResource(make_shared<WebHookResource>(), "/webhook");
        server.addEntryPoint(EntryPointType::Application, &make_unique<Index, const WEnvironment&>);

        server.run();
    }
    catch ( WServer::Exception& e ) { cerr << "exception in server: " << e.what() << endl; code = -1; }
    catch (     std::exception& e ) { cerr << "std exception: "       << e.what() << endl; code = -1; }

    return code;
}

When I build it with http connector it works as expected, but when trying to use fcgi, it seems like long polling for some reason blocks all other requests, I can't even reload the page.
I want to use Caddy as reverse proxy. I also tried nginx with the configuration example from the wiki page Fastcgi_on_nginx

Actions #1

Updated by Andrey Alekseev 7 days ago

Just ran spawn-fcgi with -p key to look what is happening in wireshark. As I can see, request is actually sent from nginx to wt app, so there is no reverse proxy problem, but a bug or misconfiguration of Wt.
I tried default non-modified wt_config.xml, alo tried switching to dedicated processes. No matter what I do, curl http://localhost/webhook will be stuck when page is open

Actions

Also available in: Atom PDF