Giter VIP home page Giter VIP logo

Comments (4)

j4nSolo avatar j4nSolo commented on May 24, 2024 1

I solved it. It obvioulsy had nothing to do directly with NiceGUI but with the reverse proxy setup on nginx. I leave the solution here in case someone faces the same problem:

I solved it by adding the following configuration to my nginx config file:

proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";

thanks to this source: https://www.nginx.com/blog/websocket-nginx/

from nicegui.

tjakobi avatar tjakobi commented on May 24, 2024 1

Interestingly I had exactly the same issue Invalid websocket upgrade (further occurrences of this error will be logged with level INFO). However, I am using Apache instead of nginx.

For reference, this is the Apache config that works for me in combination with nicegui (1.4.22). Maybe this could also be helpful as an example in the repository since the translation from nginx to Apache was not trivial (at least for me).

<VirtualHost server.name.org:80>
    # only used for mapping HTTP to HTTPS
    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
    RewriteCond %{SERVER_NAME} =server.name.org
    RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
    ServerName server.name.org
</VirtualHost>

<VirtualHost server.name.org:443>

    # SSL configurations would go here...
    
    RequestHeader set X-Forwarded-Proto "https"
    
    ServerName server.name.org
    ServerSignature Off
    
    # below the important parts required for WS to work 
    RewriteEngine On
    RewriteCond %{HTTP:Connection} Upgrade [NC]
    RewriteCond %{HTTP:Upgrade} websocket [NC]
    RewriteRule /(.*) ws://127.0.0.1:8080/$1 [P,L]
    
    ProxyPreserveHost On
    
    <Location />
        ProxyPass http://127.0.0.1:8080/
        ProxyPassReverse /
    </Location>
</VirtualHost>

from nicegui.

rodja avatar rodja commented on May 24, 2024

We have such a configuration in one of our examples: https://github.com/zauberzeug/nicegui/tree/main/examples/nginx_subpath. Maybe it is not visible enough?

from nicegui.

rodja avatar rodja commented on May 24, 2024

That looks very helpful indeed @j4nSolo. Would you like to create a pull request with a apache_subpath example similar to the existing nginx_subpath?

from nicegui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.