NGINX - performance HTTP server Support Forums

Please login or register.

Login with username, password and session length
Advanced search  

News:

Welcome to the Unofficial (YET) support forums for NGINX, a performance HTTP server.

Pages: [1]   Go Down

Author Topic: IPB3 FURL over nginx  (Read 3212 times)

0 Members and 1 Guest are viewing this topic.

DarkPepe

  • Newbie
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 1
    • View Profile
IPB3 FURL over nginx
« on: September 01, 2009, 12:26:44 PM »
Hi, I'm having several problems to set up Invision Board 3 with the Friendly URL structure under Nginx.

The first problem I have it's the rewrite rules for the FURL system wich are formated for htaccess but not for nginx.. and I really dont know how to convert them:

Code: [Select]
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !\..+$
RewriteRule . /index.php [L]
</IfModule>


Probably my second problem is related with the FURL structure but I cant confirm... some of the links generated by IPB are returning a 502 error page, while the same board over regular apache (without nginx) works flawless...

I really dont want to use apache anymore (resource hog) but Im a bout to crack my head with this rewrite stuff in nginx..

I hope someone can help me :)

Cheers.
Logged

bmn

  • Newbie
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 1
    • View Profile
Re: IPB3 FURL over nginx
« Reply #1 on: September 05, 2009, 04:55:58 AM »
IPB is one of many scripts that (assuming you're in the correct mode) gets its data from the URI, and all you need to do regarding rewrite rules is to point to index.php. Thus scripts of this type all use the same config in nginx:

Supposing the forum is in a directory /forum. This must be after any parent directories' location blocks (e.g. /) or they will take priority. I believe this only works in nginx 0.7+, as earlier versions don't have the try_files command.

Code: [Select]
location /forum/ {
  index index.php;
  try_files $uri $uri/ /forum$uri;
}

In IPB3 there are three URI modes:

With "Use .htaccess mod_rewrite" enabled, you need the above config and fully friendly URIs are used.
/forum/topic/1-default-topic/

With the above disabled and "URL type" set to "Path info", no config is required, but index.php is added to the FURL. This may not work in some Apache setups, but nginx has no trouble with it.
/forum/index.php/topic/1-default-topic/

With mod_rewrite disabled and "URL type" set to "Query string", no config is required, but index.php? is added to the FURL. This is the most compatible option, but also the least friendly.
/forum/index.php?/topic/1-default-topic/
« Last Edit: September 05, 2009, 05:08:22 AM by bmn »
Logged

darvil

  • Newbie
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 2
    • View Profile
Re: IPB3 FURL over nginx
« Reply #2 on: September 23, 2009, 01:25:32 AM »
Hi there,

Here's my config

I'm using php-fpm and the latest nginx.
forum is in discuzz subdirectory and not the typical forum


Code: [Select]
server {
        listen   80;
        server_name  domain.com;
        rewrite ^/(.*) http://www.domain.com/$1 permanent;
}

server {
  listen 80;
  server_name  www.domain.com;
  root /home/user/domain.com;
  location / {
    index index.php index.html index.htm;
    }

# This is the php-fpm section.
  location ~ \.php$ {
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include        fastcgi_params;

 }

 location /discuzz/ {
   index index.php index.htm index.html;
   try_files $uri $uri/ /discuzz/index.php?q=$uri;
# try_files $uri $uri/ /discuzz$uri;
}

 location /discuzz {
   index index.php index.htm index.html;
   try_files $uri $uri/ /discuzz/index.php?q=$uri;
# try_files $uri $uri/ /discuzz$uri;
}


  location ~ /\.ht {
            deny  all;
          }


     }



edit:  I managed to solve the issue as to why I couldn't browse the directory.  The above recommendation wasn't right for me.  I had to use this to make it browsable for me.

try_files $uri $uri/ /discuzz/index.php?q=$uri;

I also found out I have to make a location / for both /discuzz and /discuzz/.  I guess there is no way around having 2 separate entries just so both domain.com/discuzz and domain.com/discuzz/ would work.

I almost have it but now I have 2 more issues to resolve.  First it seems that I am unable load the graphics that are part of the forum skin (permission denied).  Since the files are owned by a specific user and php-fpm is ran by that user, I'm not sure why the graphics can't be loaded.  Any ideas?

The other issue I have is that domain.com not working.  I get a 403 error when I go to domain.com or even if I specifically type a file (domain.com/index.html).  Is there something wrong with my config to cause this issue?
« Last Edit: September 23, 2009, 08:34:02 PM by darvil »
Logged

darvil

  • Newbie
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 2
    • View Profile
Re: IPB3 FURL over nginx
« Reply #3 on: September 26, 2009, 10:01:22 PM »
I got it all figured out.

Had to do with me forgetting to put the user line in nginx.
Logged
Pages: [1]   Go Up
« previous next »
 

Page created in 0.036 seconds with 23 queries.