Support #13719
openHow to configure reverse proxy for server push with fcgi
0%
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
Updated by Andrey Alekseev 12 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
Updated by Matthias Van Ceulebroeck 1 day ago
- Status changed from New to Feedback
- Assignee set to Andrey Alekseev
Hello Andrey,
We are going to deprecate the FCGI backend, in favor of wthttp
. I have noticed that 2.4 introduced some changes that requires some configuration changes, and all our FCGI documentation is greatly out-of-date.
Internally, we discussed this, and came to the consensus that using FCGI for newer applications would be discouraged by us. There is of course the case for older applications, so we will keep the backend in there.
If you are willing to spend some effort, and provide a patch, I would be happy to verify it, and include it, but we are not going to spend development time on FCGI any longer.