Jump to content

Question

Posted

Hi Guys,

 

can some people show me their nginx configs for blesta?

I had it working using the 'try_files $uri' way of doing things, but I reinatlled my server and forgot how I made it work before.

I am currently using a method i found on here elsewhere (thanks to that poster),

but I would like to get back to the 'try_files $uri' method as it was much cleaner and simpler.

 

Here is what i'm currently using...

     location / {
           error_page     404 = @blesta; #IF file doesn't exist
           log_not_found  off;
           }

      location ~ \.php$ {
            try_files $uri =404;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_connect_timeout 60;
            fastcgi_send_timeout 180;
            fastcgi_read_timeout 180;
            fastcgi_buffer_size 128k;
            fastcgi_buffers 4 256k; #
            fastcgi_busy_buffers_size 256k;
            fastcgi_temp_file_write_size 256k;
            fastcgi_intercept_errors on;
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;
            include fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            }

            # Disallow access to any file with .pdt extension
        location ~ (\.pdt) {
            return 403;
            }

        if (!-e $request_filename){
            rewrite ^(.*)$ /index.php;
            }

        #Core rewrite
        location @blesta {
            rewrite ^(.*)$/index.php/(.*) /$1  permanent;
            }
}

 

I remember before I was using something a lot simpler, something like...

 location / {

               try_files $uri $uri/ 

               then the fastcgi_pass stuff

6 answers to this question

Recommended Posts

  • 0
Posted

Messed with this for a while after posting the question.

I have come up with the following which seems to work....

 

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

      location ~ \.php$ {
            try_files $uri =404;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_connect_timeout 60;
            fastcgi_send_timeout 180;
            fastcgi_read_timeout 180;
            fastcgi_buffer_size 128k;
            fastcgi_buffers 4 256k; #
            fastcgi_busy_buffers_size 256k;
            fastcgi_temp_file_write_size 256k;
            fastcgi_intercept_errors on;
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;
            include fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            }


            # Deny all attempts to access hidden files
            # such as .htaccess, .htpasswd, .DS_Store (Mac).
        location ~ /\. {
            deny all;
            }
            
            # Disallow access to any file with .pdt extension
        location ~ (\.pdt) {
            return 403;
            }
}

 

If anyone wants to add to this please feel free to post.

  • 0
Posted

This is what I have setup on my Arch box (minus all the fastcgi, security and optimization I have):

 

location / {
    root   /srv/http/blesta.netops.local/public;
    index  index.html index.htm index.php;
    
    autoindex off;
    rewrite ^(.*)$ https://$http_host$request_uri redirect;

    if (!-e $request_filename) {
        rewrite ^(.*)$ /index.php;
    }

    if ($request_uri ~ "^(.*)/install.php$") {
        rewrite install.php /%1/install/ redirect;
    }
}

location ~ ^/(.*/)?\.git(/|$) {
    deny all;
}

location ~ \.(pdt)$ {
    deny all;
}

 

-Adam

 

  • 0
Posted
16 hours ago, Adam said:

This is what I have setup on my Arch box (minus all the fastcgi, security and optimization I have):

 


location / {
    root   /srv/http/blesta.netops.local/public;
    index  index.html index.htm index.php;
    
    autoindex off;
    rewrite ^(.*)$ https://$http_host$request_uri redirect;

    if (!-e $request_filename) {
        rewrite ^(.*)$ /index.php;
    }

    if ($request_uri ~ "^(.*)/install.php$") {
        rewrite install.php /%1/install/ redirect;
    }
}

location ~ ^/(.*/)?\.git(/|$) {
    deny all;
}

location ~ \.(pdt)$ {
    deny all;
}

 

-Adam

 

yeah I had similar before.

Give the try_files way a go. It should make a noticable difference in speed.

Using if statements and rewrites is slower because they are read and processed for each request.

  • 0
Posted
6 hours ago, speed2host said:

Hey good post. But where exactlly should we add this lines? :) Were not all gurus in dev .. i run a Centos 7 on Apache 

 

 

Best Regards

This goes in your nginx config file. If you need further help, ask your technical staff or hire a server management company.

-Adam

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...