Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
PostPosted: Sun Mar 04, 2012 8:36 am 
Offline
Newbie

Joined: Sun Mar 04, 2012 8:26 am
Posts: 3
Hello there!

I've just recently set up an nginx webserver after reading about it being better with resources than Apache.

Having experience with Apache before (my shared hosting uses Apache) working in the nginx environment is completely new to me o.O

I'm trying to install SpaceBukkit on my Linode for Minecraft Server management, and am struggling as to where to put:

Code:
location / {
        index  index.php /index.php;
        rewrite (.*) /app/webroot$1 ;
}

location /app/ {
        rewrite ^$ webroot/ ;
        rewrite (.*) webroot$1 ;
}

location /app/webroot/ {
        if (!-e $request_filename) {
                rewrite ^(.*)$ /index.php?$1 ;
        }
        index index.php /index.php;
}


Spacebukkit is located in a directory (sub.domain.tld/admin) of the server_name (sub.domain.tld) and adding /admin behind every tag doesn't seem to function and gives an error 500 code. How may I modify the above code to function in a directory?

Thanks!

EDIT: Also, I'd like it so that if users visit the site via another domain (such as domain.tld/minecraft/admin) they would be able to access the site with the rewrite rules applied.

It's like having a .htaccess in the directory, but since nginx doesn't support .htaccess... oh well :P


Top
   
 Post subject:
PostPosted: Sun Mar 04, 2012 8:56 am 
Offline
Senior Member
User avatar

Joined: Thu Feb 16, 2012 9:01 pm
Posts: 52
First. Try to avoid if and rewrite at first. Everything here can be acheived with try_files and root. When you think you need rewrite use location ~ regex {... } and see how far you get.

Code:
location / { 
        root /app/webroot;
        index  index.php /index.php;
        try_file $url $url/ ;
}

location /app/ {
        root webroot ;
        try_files $url ;
}

location /app/webroot/ {
        try_files $url $url/  /index.php?$uri&$args ;
}
 


Untested but you get the gist


Top
   
 Post subject:
PostPosted: Sun Mar 04, 2012 9:52 am 
Offline
Newbie

Joined: Sun Mar 04, 2012 8:26 am
Posts: 3
After changing $url to $uri the configuration you submitted doesn't function: it returns me a 500 Internal Server Error. Thanks for your assistance though!

The config I used is derived from the script's webpage: http://spacebukkit.xereo.net/wiki/index ... ginx_stuff

EDIT:

I guess I wasn't specific enough. After hours upon hours of tinkering with the configurations, I am still unable to accomplish the simple task of modifying the configuration so that it works in a subdirectory.

My latest attempt, this, doesn't work at all :(

Code:
server {
        #listen   80; ## listen for ipv4; this line is default and implied
        #listen   [::]:80 default ipv6only=on; ## listen for ipv6

        root /var/www/minecraft;
        index index.php;

        # Make site accessible from _
        server_name _;

        location /admin {
                index  index.php /index.php;
                rewrite (.*) /app/webroot$1 ;
        }

        location /admin/app/ {
                rewrite ^$ webroot/ ;
                rewrite (.*) webroot$1 ;
        }

        location /admin/app/webroot/ {
                if (!-e $request_filename) {
                        rewrite ^(.*)$ /index.php?$1 ;
                }
                index index.php /index.php;
        }

        location ~* \.php$ {
                try_files $uri = 404;
                include /etc/nginx/fastcgi_params;
                fastcgi_pass unix:/tmp/phpfpm.sock;
                fastcgi_index index.php;
        }
}


Top
   
PostPosted: Sun Mar 18, 2012 4:36 pm 
Offline

Joined: Sun Mar 18, 2012 4:33 pm
Posts: 1
Seems like you are trying to setup cakephp to work via nginx?
just google cakephp on nginx. there is no rewrite really need for nginx. just point your domain root into webroot directory
....
location / {
root /var/www/example.com/public/app/webroot/;
index index.php index.html index.htm;
if (-f $request_filename) {
break;
}
....


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group