不允许用户使用指令 [英] User diretive is not allowed

查看:165
本文介绍了不允许用户使用指令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为OsTicket配置创建虚拟主机. 在文件vim /etc/nginx/sites-available/osticket.conf中,我插入了以下行:

I'm creating a virtual host for the OsTicket configuration. In the file vim /etc/nginx/sites-available/osticket.conf I'm inserting these lines:

user  nginx;
worker_processes 1;

events {
    worker_connections  1024;
}

http {
    include         mime.types;
    default_type    application/octet-stream;
    sendfile        on;
    charset         utf-8;
    gzip            on;
    gzip_types      text/plain application/xml text/javascript;
    gzip_min_length 1000;

    index index.php index.html index.htm;

    # Rewrite all requests from HTTP to HTTPS
    server {
        listen 80;
        server_name 192.168.0.24;
        rewrite ^ http://192.168.0.24 permanent;
    }

    server {
        listen 443;
        server_name 192.168.0.24;
        ssl on;
        ssl_certificate /etc/nginx/certs/cert.pem;
        ssl_certificate_key /etc/nginx/certs/cert.key;

        keepalive_timeout 70;

        root /var/www/osticket;

        set $path_info "";

        location ~ /include {
            deny all;
            return 403;
        }

        if ($request_uri ~ "^/api(/[^\?]+)") {
            set $path_info $1;
        }

        location ~ ^/api/(?:tickets|tasks).*$ {
            try_files $uri $uri/ /api/http.php?$query_string;
        }

        if ($request_uri ~ "^/scp/.*\.php(/[^\?]+)") {
            set $path_info $1;
        }

        if ($request_uri ~ "^/.*\.php(/[^\?]+)") {
            set $path_info $1;
        }

        location ~ ^/scp/ajax.php/.*$ {
            try_files $uri $uri/ /scp/ajax.php?$query_string;
        }

        location ~ ^/ajax.php/.*$ {
            try_files $uri $uri/ /ajax.php?$query_string;
        }

        location / {
            try_files $uri $uri/ index.php;
        }

        location ~ \.php$ {
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
            fastcgi_param  PATH_INFO        $path_info;
            fastcgi_pass   192.168.0.24:8888;
        }
    }
}

当我执行service nginx restart时,出现以下错误:

And when I do service nginx restart I get the following error:

在此处输入图片描述

如果使用命令nginx -t,则会出现以下错误:

If you use the command nginx -t I get the following error:

在此处输入图片描述

在Nginx服务器日志中,出现以下错误:

In the nginx server logs I get the following error:

此处不允许使用用户"指令 /etc/nginx/sites-enabled/osticket.conf:1

"user" directive is not allowed here in /etc/nginx/sites-enabled/osticket.conf:1

如何解决nginx服务正常工作的问题.

How can I solve the problem for the nginx service to work.

推荐答案

默认情况下,sites-enabled文件夹中的所有配置文件都包含在nginx.conf配置中,该配置已经具有http块和大多数内容您正在设置.

All configuration files inside the sites-enabled folder are by default included within the nginx.conf configuration, which already has the http block and most of the things you are setting.

您应该在osticket.conf文件中仅包含服务器块.删除所有其他内容,您应该会得到类似以下内容的

You should have only your server blocks in the osticket.conf file. Remove everything else and you should end up with something like:

server {
    listen 80;
    server_name 192.168.0.24;
    rewrite ^ http://192.168.0.24 permanent;
}

server {
    listen 443;
    server_name 192.168.0.24;
    ssl on;
    ssl_certificate /etc/nginx/certs/cert.pem;
    ssl_certificate_key /etc/nginx/certs/cert.key;

    keepalive_timeout 70;

    root /var/www/osticket;

    set $path_info "";

    location ~ /include {
        deny all;
        return 403;
    }

    if ($request_uri ~ "^/api(/[^\?]+)") {
        set $path_info $1;
    }

    location ~ ^/api/(?:tickets|tasks).*$ {
        try_files $uri $uri/ /api/http.php?$query_string;
    }

    if ($request_uri ~ "^/scp/.*\.php(/[^\?]+)") {
        set $path_info $1;
    }

    if ($request_uri ~ "^/.*\.php(/[^\?]+)") {
        set $path_info $1;
    }

    location ~ ^/scp/ajax.php/.*$ {
        try_files $uri $uri/ /scp/ajax.php?$query_string;
    }

    location ~ ^/ajax.php/.*$ {
        try_files $uri $uri/ /ajax.php?$query_string;
    }

    location / {
        try_files $uri $uri/ index.php;
    }

    location ~ \.php$ {
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
        fastcgi_param  PATH_INFO        $path_info;
        fastcgi_pass   192.168.0.24:8888;
    }
}

这篇关于不允许用户使用指令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆