Steps to configure Nginx in Pyscada

1. Find the nginx configuration file nginx.conf

1. View the actual call configuration file of Nginx

ps aux|grep nginx
root              352   0.0  0.0  2468624    924   ??  S    10:43上午   0:00.08 nginx: worker process  
root              232   0.0  0.0  2459408    532   ??  S    10:43上午   0:00.02 nginx: master process /usr/sbin/nginx -g daemon on;  
root             2345   0.0  0.0  2432772    640 s000  S+    1:01下午   0:00.00 grep nginx

It can be seen that the Nginx path is /usr/sbin/nginx

2. Check the Nginx configuration file path

Use the -t parameter of Nginx to check the configuration, and you can know the path of the configuration file actually called and whether the call is valid.

/usr/sbin/nginx -t
nginx: the configuration file etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

2. Enter the nginx.conf file, find the directory path containing conf.d and configure it

can be seen:

include /etc/nginx/conf.d/*.conf;

Move the configuration file downloaded in the Pyscada document into the /etc/nginx/conf.d directory: (you can also move it while downloading)
The path where pyscada.conf is located

cd /etc/nginx/sites-enabled
mv pyscada.conf /etc/nginx/conf.d

Enter pyscada.conf to modify it

cd /etc/nginx/conf.d
nano pyscada.conf

Because there is no https certificate, and there is no need to use https, just use http, so delete the content and modify the file to the following:

# pyscada.conf

# the upstream component nginx needs to connect to
upstream app_server {
    
    
        server unix:/tmp/gunicorn.sock fail_timeout=0; # for a file socket
        #server 127.0.0.1:8000 fail_timeout=0; # for a file socket
}

# configuration of the server
server {
    
    
    listen     8081;
    listen   [::]:8081;
    server_name _;          # substitute your machine's IP address or FQDN
    #return 301 https://$server_name$request_uri;
    #return 301 https://$host$request_uri;

     # Django media
        location /media  {
    
    
                alias /var/www/pyscada/http/media;  # your Django project's media files - amend as required
        }

        location /static {
    
    
                alias /var/www/pyscada/http/static; # your Django project's static files - amend as required
        }
        location /measurement {
    
    
                alias /home/pyscada/measurement_data_dumps; # to support download of measurement files via admin backend - amend as required
        }

        location / {
    
    
            # checks for static file, if not found proxy to app
            try_files $uri @proxy_to_app;
        }

        location @proxy_to_app {
    
    
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header Host $http_host;
            proxy_redirect off;

            proxy_pass   http://app_server;
        }

}

Here, port 8080 is already occupied by openplc, so it is changed to port 8081, and readers can modify it according to their own conditions. After modification, restart Nginx.

nginx -s reload

The pyscada configuration ends here. Perform follow-up configuration according to official documents, and finally enter the following command to open pyscada.

sudo systemctl start pyscada

Open the browser and enter localhost:8081 to enter the pyscada login interface, enter the user name and password to log in successfully.
pyscada login interface

Guess you like

Origin blog.csdn.net/QQ395879676/article/details/115421848