What I’m trying to do: I’m following the nginx beginner’s guide to create a web server (static content as 1st step) on my raspberry PI. The guide tells me " create the /data/www
directory and put an index.html
file with any text content into it and create the /data/images
directory and place some images in it"
Where I’m stuck: where and how do I create these directories? Using sudo mkdir with my pi userid, at the same level as /etc/… the user directive in the nginx.conf “user www-data;”
What I’ve already tried: as I’m new to nginx, I do prefer to follow the doc vs. messing around 
Thank you for your help.
1 Like
This is determined by the root path that you set in the configuration. Here is a snippet from the documentation.
NGINX Web Server
server {
location /images/ {
root /data;
}
location / {
proxy_pass http://www.example.com;
}
}
The root directive specifies the file system path in which to search for the static files to serve. The request URI associated with the location is appended to the path to obtain the full name of the static file to serve. In the example above, in response to a request for /images/example.png, NGINX Plus delivers the file /data/images/example.png.
The proxy_pass directive passes the request to the proxied server accessed with the configured URL. The response from the proxied server is then passed back to the client. In the example above, all requests with URIs that do not start with /images/ are be passed to the proxied server.
Hello,
Thank you for this info.
Here my basix nginx.conf
user pi ;
http{
server{
listen 8080; # to test a specific port vs. 80
location / {
root /home/pi/data/www ;
}
location /images/ {
root /home/pi/data ;
}
}
}
events{}
And it is working ok.
Not sure about the need / influence of the “user pi;” directive.
Same behavior with or without this directive.
My next steps:
- use the nginx reverse proxy capabilities
- link to the letsencrypt certificates for ssl access from the internet.
Cheers,
Benoit.
1 Like