Reverse Proxy for Blazor WebServer

#1
Hello,

First of all, I should mention that:
1) I have very limited experience with OLS configuration
2) I use OLS through a CyberPanel installation
3) I mostly write my vhosts by hand (I'm not familiar with the gui of OLS)

To the point.

I recently created a Blazor Server WebApp which i'm trying to make publicly available using OLS's reverse proxying capabilities. After doing a somewhat extensive research to find out how to acomplish this, I only managed to make the HTTP part of the page available (*read PS1 for a brief explanation on how Blazor Server listens for connections) by completely disabling https in my app and using the following configuration:


NGINX:
docRoot                    $VH_ROOT/public_html
vhDomain                $VH_NAME
vhAliases                www.$VH_NAME
adminEmails                [REDUCTED]
enableGzip                1
enableIpGeo                1

errorlog $VH_ROOT/logs/$VH_NAME.error_log {
    useServer            0
    logLevel            ERROR
    rollingSize            10M
}

accesslog $VH_ROOT/logs/$VH_NAME.access_log {
    useServer            0
    logFormat            "%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i""
    logHeaders            5
    rollingSize            10M
    keepDays            10 
    compressArchive        1
}

extprocessor Backend {
    type             proxy
    address         127.0.0.1:5000
    maxConns         2000
    initTimeout     20
    retryTimeout     0
    respBuffer         0
}

context / {
    type            proxy
    handler            Backend
    addDefaultCharset    off
}
I won't be surprised if this configuration is a war crime but at least i tried.

That said, i try to also support the https part of my page and additional WS/WSS forwarding as its needed from the app.
Can someone help me to figure this out, if possible at all?

Thank you in advance.

---
PS1: A blazor Server usually works by listening on two user-specified ports (5000 for http/ws and 5001 for https/wss, in my case). If both http/https enabled, the application will force the use of https (by forwarding you to the https listener).
 

Pong

Administrator
#2
You'd better use OLS Web Admin to avoid sytax error, which might not easy to spot.

so your http port 80 proxy is ok, right?

You may need to create separate virtual host for https , then set it to proxy to 5001.

but question is if you can force http to https, you don't need http virtual host at all.

Just use one virtual host, set port 80 and 443 pointing to the same virtual host, enforce http to https through rewite rule, backend proxy only need to direct to 127.0.0.1:5001
 
Top