• Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    Flask Webserver using nginx

    Official EVOK API
    2
    6
    1790
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • J
      juntiedt last edited by

      I have an alternativ UniPi control panel runing using Flask webserver. For the four 1w temp sensors I include graphical gauges. It works perfectly with long polling. Now i would like to use websockets (better performance) and nginx, which is also used with evok.
      In the Flask documentation I found the following guidelines:

      Using nginx as a WebSocket Reverse Proxy
      It is possible to use nginx as a front-end reverse proxy that passes requests to the application. However, only releases of nginx 1.4 and newer support proxying of the WebSocket protocol. Below is a basic nginx configuration that proxies HTTP and WebSocket requests:

      server {
          listen 80;
          server_name _;
      
          location / {
              include proxy_params;
              proxy_pass http://127.0.0.1:5000;
          }
      
          location /socket.io {
              include proxy_params;
              proxy_http_version 1.1;
              proxy_buffering off;
              proxy_set_header Upgrade $http_upgrade;
              proxy_set_header Connection "Upgrade";
              proxy_pass http://127.0.0.1:5000/socket.io;
          }
      }
      

      In etc/nginx/sites-enabled I found a evok File. Can I use this file for my configuration? evok and my app would both come in on port 80?

      I also followed these guidelines:
      https://iotbytes.wordpress.com/python-flask-web-application-on-raspberry-pi-with-nginx-and-uwsgi/
      up to point 10 all worked ok, but with nginx configuration I don't know how to coexist with evok.

      As I am not a Raspian/Debian/Unix specialist, any help is very welcome.

      1 Reply Last reply Reply Quote 0
      • T
        TomasKnot last edited by TomasKnot

        Evok uses the same method to run both the API and the server on the same port. You can indeed use it by modifying the /etc/nginx/sites-enabled/evok file.

        That said, MAKE SURE TO BACK UP YOUR CARD FIRST! Messing with the configuration file can be somewhat error prone.

        1 Reply Last reply Reply Quote 0
        • J
          juntiedt last edited by

          Hi Tomas,

          if I listen to port 80 and use location /fl (like /ws for evok), how can I then call this location from my chrome browser?

          1 Reply Last reply Reply Quote 0
          • T
            TomasKnot last edited by

            @juntiedt

            If you set it up correctly you can put IP_ADDRESS/fl into your browser to visit the website.

            1 Reply Last reply Reply Quote 0
            • J
              juntiedt last edited by

              Hi Tomas,

              I changed evok File in sites-enabled and called "sudo service nginx restart" or "sudo service nginx reload" but nginx seems to not recognize the changes in evok File. Even rebooting did not load the new configuration. What am I doing wrong? :-(

              T 1 Reply Last reply Reply Quote 0
              • T
                TomasKnot @juntiedt last edited by TomasKnot

                @juntiedt

                You must have made your changes wrong I'm afraid. Try "sudo systemctl status nginx". NGINX configuration is documented in detail on the NGINX project website, where you can find more help on how to create your desired configuration. Evok doesn't use any non-standard option that I am aware of.

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post