Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problems with nginx.conf

Tags:

nginx

This is my first time using nginx and I'm having some problems configuring an nginx.conf file. What I have is

server {
    location ~ /(application|system) {
        deny all;
        return 404;
    }

    rewrite  ^(.*)$  /index.php/$1  break;
}

In case it's not clear; I'm trying to block access to the directories application and system and rewrite all other requests to the index.php. I've tried validating the nginx.conf file using: ian@ubuntu:~$ sudo nginx -t -c path_to_conf_file but get [emerg]: unknown directive "server".... Any ideas what I might be doing wrong?

like image 635
Ian Burris Avatar asked Dec 09 '22 07:12

Ian Burris


1 Answers

You need to make sure the server directive is inside of the http directive if I recall.

eg:

http {

    //various nginx settings here

    server {
        //server stuff here
    }

}
like image 135
kniteli Avatar answered Dec 29 '22 22:12

kniteli