• This forum has been archived. New threads and replies may not be made. All add-ons/resources that are active should be migrated to the Resource Manager. See this thread for more information.

Setup SEO Full Friendly URLs on nginx

Where in documentation you saw that?
I don't have that info and is not present in the Wiki also. I will ask Igor to see what is going on.
 
So the deny directive is used to specify certain actions to be allowed or prevented and not to specify that the location is for internal use only ;)
 
What is that link? Is pointing to a domain for sale.
Did Igor confirmed what was stated above, in previous posts?

I'm just looking at the code and is telling me otherwise:
Code:
void
ngx_http_handler(ngx_http_request_t *r)
{
	...
    if (!r->internal) {
    	...
    } else {
        cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module);
        r->phase_handler = cmcf->phase_engine.server_rewrite_index;
    }
	...
    r->write_event_handler = ngx_http_core_run_phases;
    ngx_http_core_run_phases(r);
}

ngx_int_t
ngx_http_core_find_config_phase(ngx_http_request_t *r,
    ngx_http_phase_handler_t *ph)
{
    ...
    if (!r->internal && clcf->internal) {
        ngx_http_finalize_request(r, NGX_HTTP_NOT_FOUND);
        return NGX_OK;
    }
    ...
}
I don't see anywhere access being blocked to location, as is intended to be used in first place by .htaccess files made by Kier. The "internal" condition is just a simple redirect, nothing more.
 
What is that link? Is pointing to a domain for sale.
Did Igor confirmed what was stated above, in previous posts?
Sorry Edited to the correct URL

I don't see anywhere access being blocked to location, as is intended to be used in first place by .htaccess files made by Kier. The "internal" condition is just a simple redirect, nothing more.

True Kier did not include any EXTRA apache protective measures, however, It's a common/good practice to protect the folders for internal use only (MVC way of doing business)
I am no php genius, (I am a .NET guy) All I can say is that's what we do with IIS.
 
That is exactly my point. :)
"internal" is used to do an internal redirect, that's all.

Edit: after more digging into code, it looks like "internal" restricts /location to internal redirects or subrequests (not requests), like the Wiki says. Either ways, it does not do what allow/deny is intended to do in first place: allowing/denying an address to access a resource.

Personally, I would use "internal" in a config only when I define an alias, so the sub-requests are not blocked.
 
That is exactly my point. :)
"internal" is used to do an internal redirect, that's all.
No that's exactly not the point :) (i'm not trying to be snobby here, sorry but have to explain)

internal is used to designate a location block as internal. no public request will be allowed, only the application itself can access that block. In other words it's like moving that block outside of the /public root folder.
Just read the definition I posted above.

haha now let's move on ... I really want to take a look at your app though...:D soon
 
I wrote to Igor about this, LOL. :D
Let's hope Google Apps will not trash all spanned emails that are waiting to be delivered into inbox, once my server is back online. I expect 1000 emails to explode in my box...
 
From the start, internal was designed to be used as internal 404, as explained in the Wiki. I don't understand why you keep saying that is better to use it, when the function was not designed for the purpose of blocking access to a location?
It is exactly used for the purpose of blocking external access to a location.
 
Pardon me for reviving a very old thread.. Buuuuuuuuuut.

What was the conclusion of the 'correct' nginx config file for a xenforo running on it?
I want to run xf on the root of my server. I also want to run it with full seo on. I still want to be able to disable seo and still have the site working.

Can you please help me?

below you see my current 'default' nginx config.
Code:
server {
        listen   80;
        root /usr/share/nginx/www;
        index index.php;

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

        location /doc {
                root /usr/share;
                autoindex on;
                allow 127.0.0.1;
                deny all;
        }

        location /images {
                root /usr/share;
                autoindex off;
        }
        location ~ \.php$ {
                fastcgi_pass 127.0.0.1:9000;
                fastcgi_index index.php;
                include fastcgi_params;
        }
}
 
I didn't have much luck with the try_files block in nginx, I use the dreaded IF. Replace your "location /" with this, replacing the try_files parameter...
Code:
location / {
   if (!-e $request_filename) {
     rewrite ^(.*)$ /index.php last;
   }
}

You might also have to make sure that your SCRIPT_FILENAME in your fastcgi_params is correct, it should look something like this (at least it does in mine):
Code:
fastcgi_param  SCRIPT_FILENAME  /blah/blah/location/to/your/xf/installation/$fastcgi_script_name;

I'm not sure what you mean by "disable SEO and still have the site working".
 
I've got the impression that this setup seems to work for people:

Code:
location /xf/ {
    try_files $uri $uri/ /xf/index.php?$uri&$args;
    index index.php index.html;
}

location /xf/(internal_data|library)/ {
    internal;
}

location ~ \.php$ {
    fastcgi_pass    127.0.0.1:9000;
    fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include         fastcgi_params;
}
(Changing the /xf/ stuff as needed.)
 
Yes, thanks Mike, I went back to Floren's post with those instructions and tried it with mine, and it works pretty nice now.

Also, I don't know why this doesn't work for me to protect the internal_data and library directories...
Code:
location /xf/(internal_data|library)/ {
  internal;
}
If I split them out separately like this, it works fine.
Code:
location /xf/internal_data/ {
	internal;
}
location /xf/library/ {
       internal;
}
 
Code:
location /xf/ {
    try_files $uri $uri/ /xf/index.php?$uri&$args;
    index index.php index.html;
}

When I have that enabled I am having major problems with images and javascripts doesn't seem to work.
Commenting out those lines solves the issue.

my full config for that virtual site is
Code:
server {
    listen   80;
    server_name www.xyz.com xfprod.xxx.com xxx.com;
    access_log /srv/www/xxx.com/logs/access.log;
    error_log /srv/www/xxx.com/logs/error.log;

    location / {
        root   /srv/www/xxx.com/public_html;
        index  index.php index.html index.htm;
    }
location /xf/ {
    try_files $uri $uri/ /xf/index.php?$uri&$args;
    index index.php index.html;
}

location /xf/internal_data/ {
        internal;
}
location /xf/library/ {
       internal;
}

    location ~ \.php$ {
        include fastcgi_params;
        fastcgi_pass  127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param  SCRIPT_FILENAME  /srv/www/xxx.com/public_html$fastcgi_script_name;
    }
}
 
Site config, assumes XF installed in root:
Code:
server {
    server_name     .domain.tld;

    index   index.html index.php;
    root    /var/www/domain.tld;

    location / {
        try_files       $uri $uri/ /index.php?$uri&$args;
    }
    location ~* ^.+\.(jpg|jpeg|gif|css|png|js|ico|swf|wav)$ {
        add_header      Cache-Control   public;
        expires         max;
    }
    location ~ ^/(internal_data|library)/(.*)$ {
        internal;
    }
    location ~ ^(.+\.php)(.*)$ {
        include         /etc/nginx/fastcgi_params;
        include         /etc/nginx/php_params;
    }
}
server_name is .domain.tld, note that it begins with a dot, which means it matches domain.tld and any subdomains that doesnt have it's own config elsewhere.
Also I use "include /etc/nginx/php_params;" because my configuration is the same throughout my server, you can delete this line and replace it with your own configuration.

php_params:
Code:
fastcgi_param                   PATH_INFO               $fastcgi_path_info;
fastcgi_split_path_info         ^(.+\.php)(.*)$;
fastcgi_ignore_client_abort     on;

fastcgi_pass                    unix:/var/run/php-fpm.www.sock;
I use a unix socket instead of the standard tcp method, and as this doesnt work by default you wont be able to copy paste this bit of code without changing your configuration of php-fpm
 
Laric, I don't know if this would work for you, but you have a "root" directive for your "Location /" block, and you don't have that root directive for your other "Location" blocks "/xf/xxxx" blocks. Maybe this would work, it is almost identical to my set up. This is just the important php and xf stuff. No other server directives listed.

Code:
#site root
    location / {
      root  /blah/blah/public;
      index  index.html index.htm index.php;
    }

#xf root
    location /xf/ {
      root  /blah/blah/public;
      index  index.php index.html index.htm;
      try_files $uri $uri/ /xf/index.php?$uri&$args;
    }

#no access
    location /xf/internal_data/ {
      root  /blah/blah/public;
      internal;

    }

#no access
    location /xf/library/ {
      root  /blah/blah/public;
      internal;
    }

#no access
    location /xf/data/ {
      root  /blah/blah/public;
      internal;

    }

#php fast-cgi
    location ~ \.php$ {
      include /etc/nginx/fastcgi_params;
      fastcgi_pass  127.0.0.1:9000;
      fastcgi_index index.php;
      fastcgi_param  SCRIPT_FILENAME  /blah/blah/public$fastcgi_script_name;
      fastcgi_intercept_errors    on;
      fastcgi_ignore_client_abort    on;

    }
 
Code:
location /xf/ {
    try_files $uri $uri/ /xf/index.php?$uri&$args;
    index index.php index.html;
}

When I have that enabled I am having major problems with images and javascripts doesn't seem to work.
Commenting out those lines solves the issue.

my full config for that virtual site is
Code:
-snip-

You need to have the root directive in the server block rather than the / location block. (While you're at it I would recommend doing the same with the index directive)

If you still have issues after changing that, try removing the trailing / from your location blocks.
 
Top Bottom