Nginx with weewx on Raspberry pi 4

392 views
Skip to first unread message

lecoqacr...@gmail.com

unread,
Jul 29, 2022, 12:49:13 PM7/29/22
to weewx-user
Adding the web server states to add the following under the Nginx server :
  server {
       ...
      location /weewx {
          alias /home/weewx/public_html;
       }
 }
This is to be added in /etc/nginx/sites-enabled
May this be placed anywhere in the file or should it be at the end of the file?

Is there no changing of the root path from the the original to the setup.py install of /home/weewx/public_html     or is that unnecessary? 

Are there any other changes to be made in order to get access to the Raspberry Pi from without the local network to see the weewx page?
If I can be pointed in the right direction it would be appreciated. 
thank you

vince

unread,
Jul 29, 2022, 1:23:36 PM7/29/22
to weewx-user
Personally, I think the wiki is a little incorrect as written.  sites-enabled is a 'directory' containing one or more config files.  The typical config file is the 'file' /etc/nginx/sites-enabled/default within that directory (which is usually a symlink to /etc/nginx/sites-available/default).

If you want to do it that way, just add a new location block under the existing one in that file, then restart nginx.

FWIW - I don't do it that way.  I just create a symlink in the nginx directory:
      sudo ln -s /home/weewx/public_html /var/www/html/weewx
  (for a setup.py installation)


Timothy L

unread,
Aug 1, 2022, 7:41:32 PM8/1/22
to weewx...@googlegroups.com
Thank You Vince I will use the symlink

--
You received this message because you are subscribed to the Google Groups "weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/57fe10d7-414a-4f9a-a76c-59e77293bb6en%40googlegroups.com.

Ben Hohman

unread,
Aug 2, 2022, 4:20:34 PM8/2/22
to weewx-user
The default install of nginx has a link from sites-enabled
:/etc/nginx/sites-enabled $ ll
total 8
drwxr-xr-x 2 root root 4096 Aug  1 14:59 ./
drwxr-xr-x 8 root root 4096 Aug  1 15:01 ../
lrwxrwxrwx 1 root root   34 Aug  1 14:59 default -> /etc/nginx/sites-available/default

What you want in default is the lines in yellow, assuming you want to use root for something else and have your weather pages in a subfolder.

server {
        listen 80 default_server;
        listen [::]:80 default_server;

        root /var/www/html;

        index index.html index.htm index.nginx-debian.html;

        server_name _;

        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri $uri/ =404;
        }
       
        location /weewx {
        alias /home/weewx/public_html;
  }
}

Timothy L

unread,
Aug 3, 2022, 9:31:07 AM8/3/22
to weewx...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages