Stu Posted April 3, 2017 Report Share Posted April 3, 2017 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 Abdy 1 Quote Link to comment Share on other sites More sharing options...
0 Stu Posted April 3, 2017 Author Report Share Posted April 3, 2017 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. activa 1 Quote Link to comment Share on other sites More sharing options...
0 Adam Posted April 4, 2017 Report Share Posted April 4, 2017 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 activa 1 Quote Link to comment Share on other sites More sharing options...
0 Stu Posted April 4, 2017 Author Report Share Posted April 4, 2017 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. Quote Link to comment Share on other sites More sharing options...
0 speed2host Posted May 26, 2017 Report Share Posted May 26, 2017 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 Quote Link to comment Share on other sites More sharing options...
0 Adam Posted May 26, 2017 Report Share Posted May 26, 2017 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 Michael 1 Quote Link to comment Share on other sites More sharing options...
0 Michael Posted May 26, 2017 Report Share Posted May 26, 2017 Bit more information here: https://www.digitalocean.com/community/tutorials/understanding-the-nginx-configuration-file-structure-and-configuration-contexts Quote Link to comment Share on other sites More sharing options...
Question
Stu
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
Link to comment
Share on other sites
6 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.