Pyscada中配置Nginx的步骤

一、找到Nginx的配置文件nginx.conf

1.查看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

可以看出Nginx路径为 /usr/sbin/nginx

2.查看Nginx配置文件路径

使用Nginx的 -t 参数进行配置检查,即可知道实际调用的配置文件路径及是否调用有效。

/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

二、进入nginx.conf文件,找到包含conf.d的目录路径并进行配置

可以看到:

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

将Pyscada文档中下载的配置文件移动进/etc/nginx/conf.d目录中:(也可在下载时就进行移动)
pyscada.conf所在路径

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

进入pyscada.conf对其进行修改

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

因为没有https的证书,同时也不需要使用到https,使用http即可,因此对内容进行删除,将文件修改至以下:

# 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;
        }

}

此处因为8080端口已被openplc占用,因此换作8081端口,读者可视自身情况进行修改。修改结束重启Nginx。

nginx -s reload

到这里pyscada配置结束。根据官方文档进行后续配置,最后输入以下命令打开pyscada。

sudo systemctl start pyscada

打开浏览器输入localhost:8081,进入pyscada登录界面,输入用户名及密码即可成功登录使用。
pyscada登录界面

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值