Configuring nginx for file access on PLCnext FW 2024.LTS: Seeking guidance
Hello everyone,
I was excited about implementing a solution I came across, shared by Oliver in a previous discussion, which aimed at setting up access to files via a web interface on my PLCnext controller. The solution involved adding a specific location to the nginx configuration to make log files accessible for download without security restrictions. Here's the configuration that was suggested:
```nginx
location /FilesForWeb{
alias /opt/plcnext/FilesForWeb;
autoindex on;
ssi on;
add_header X-Frame-Options SAMEORIGIN;
add_header Cache-Control "max-age=0, no-cache, no-store, must-revalidate";
types { application/octet-stream .scv; }
default_type application/octet-stream;
}
```
However, upon navigating to `/opt/plcnext/config/Services/Wcm/nginx/https`, I found only a folder with two hidden files: `HttpsTls.nginx.config` and `HttpsCertificate.nginx.config`. It doesn't seem like these are the correct files for this adjustment.
My questions are:
1. Is the instruction mentioned above still applicable for PLCnext firmware version 2024.LTS?
2. Considering my findings, which configuration file name should I be looking for to apply the above changes? Or is there another location or method I should follow to implement this functionality on the latest firmware?
I'd also like to have the files downloaded directly when clicked on, instead of being opened in the browser, hence the addition of the `types` and `default_type` directives.
Looking forward to your suggestions and thank you in advance for your assistance!
Thank you,
Michel
Comments
Hello!
You have to modify file /etc/nginx/nginx.conf to put addition location.
Also don't forget to reload nginx configuration after that with nginx -s reload as root.
BR
Hello Oleksandr,
Thanks for your help with the nginx.conf file and reminding me to reload Nginx. Despite initial issues due to not being able to log in as root, I've managed to make the necessary changes as root.
P.S. Tried upgrading to 2024.0.0 LTS but faced serious connectivity issues, so I reverted to 2023.0.0 LTS and everything's back to normal.
Cheers,
Michel
Hello all,
Is there an option to not download but upload files to the controller from the web browser?
The objective is to load configuration file. There is the option to upload the controller firmware from the WBM so I think nginx is ready to do it.
Thank you!
Juan
In this earlier discussion:
... Oliver mentioned that this mechanism for uploading files is not recommended, for security reasons.
There is currently a requirement to allow file uploads and downloads from eHMI pages, but we don't know if or when this feature will appear. If this feature is important for your application, please contact you local Phoenix Contact office and the people there will collect the information required to set a suitable priority on this feature.
It is possible to transfer a file to the controller using an OPC UA client like UaExpert, but this probably doesn't help for browser-based applications.