Re: GeoIP2 Maxmind Module Support for Nginx

2019-01-22 Thread Karl Johnson
On Mon, Oct 1, 2018 at 4:49 AM anish10dec 
wrote:

> In both the cases , either geoip2 or ip2location we will have to compile
> Nginx to support .
>
> Currently we are using below two RPM's from Nginx Repository
> (http://nginx.org/packages/mainline/centos/7/x86_64/RPMS/)
> nginx-1.10.2-1.el7.ngx.x86_64
> nginx-module-geoip-1.10.2-1.el7.ngx.x86_64
>
> Is the rpm module available or is there any plan to make it available.
>
>
Hello,

I'm building nginx RPM for CentOS 6 and 7 which now include
ngx_http_geoip2_module. If this package can help and you want to test it on
a new server, just add the yum repository and install it from the testing
repo:

el7 #> yum install
https://repo.aerisnetwork.com/stable/centos/7/x86_64/aeris-release-1.0-4.el7.noarch.rpm
el7 #> yum --enablerepo=aeris-testing install nginx-more

You can find more information about this package on GitHub:
https://github.com/karljohns0n/nginx-more

Karl
___
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx

Using variable in vhost

2018-06-12 Thread Karl Johnson
Hello,

I have a nginx multi-user setup that use the same fpm config for all vhost
but each vhost has his own user so I had to set a variable in the vhost
config to set the fastcgi_pass path in the included file. This way the
vhost config is always clean.

I've read somewhere that variable in vhost is not recommended. What do you
think of this setup? It's currently working pretty well so I was wondering.

Thanks,
Karl

[root@web ~]# cat /etc/nginx/conf.d/vhosts/exemple.com.conf
server {
listen 80;
server_name exemple.com;
root /home/webtest/exemple.com/public_html;
access_log /var/log/nginx/exemple.com-access_log main;
error_log /var/log/nginx/exemple.com-error_log warn;

set $fpmuser webtest;

if ($bad_bot) { return 444; }

include conf.d/custom/restrictions.conf;
include conf.d/custom/pagespeed.conf;
include conf.d/custom/fpm-wordpress-user.conf;
}



[root@web ~]# cat /etc/nginx/conf.d/custom/fpm-wordpress-user.conf
location / {
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
try_files $uri $uri/ /index.php?$args;
}

location ~*
\.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc|woff)$ {
expires 2w;
log_not_found off;
}

location ~* \.(?:css|js)$ {
expires 1w;
add_header Pragma public;
add_header Cache-Control "public";
}

location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_buffers 8 256k;
fastcgi_buffer_size 256k;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
include fastcgi_params;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass unix:/run/php-fpm/$fpmuser.sock;
}
___
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx

Re: Tweak fastcgi_buffer

2015-07-29 Thread Karl Johnson
On Thu, Jul 23, 2015 at 3:21 PM, Maxim Dounin mdou...@mdounin.ru wrote:

 Hello!

 On Wed, Jul 22, 2015 at 05:50:12PM -0400, Karl Johnson wrote:

  Hello,
 
  I need to tweak fastcgi_buffer to 1m on a website that has heavy requests
  to avoid buffer. If I use a distro with 4096 pagesize, is it better to do
  256x 4k or 4x 256k?
 
  [root@web ~]# getconf PAGESIZE
  4096
  [root@web ~]#
 
  fastcgi_buffer_size 4k;
  fastcgi_buffers 256 4k;
 
  OR
 
  fastcgi_buffer_size 256k;
  fastcgi_buffers 4 256k;

 I would recommend the latter.  Or, alternatively, something like

 fastcgi_buffers 8 128k;

 Too many small buffers will result in extra processing overhead,
 and it's unlikely to be a good solution.


Thanks for the recommendation Maxim. There's no issue setting the buffer to
128k when the pagesize is 4k?

Karl
___
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx

Re: Adding expires on all images break nginx rewrite

2015-03-17 Thread Karl Johnson
Yes that's what I understood after few tests. I will add the expire by the
PHP script.

Thanks for all the help!

Karl

On Tue, Mar 17, 2015 at 3:07 PM, Nurahmadie Nurahmadie nurahma...@gmail.com
 wrote:


 On Wed, Mar 18, 2015 at 3:46 AM, Karl Johnson karljohnson...@gmail.com
 wrote:

 Thanks for the reply Nurahmadie.

 I changed the location to ~ ^/static/ and the rewrite works again. I've
 added a expires 1w; in this location to add an expire on all images in
 /static but it doesn't seem to apply, images give 200 OK and never cache.
 Is it the right way to do it?

 location ~ ^/static/ {
 rewrite ^/static/images/([0-9])\-([0-9]+)x([0-9]+)/(.*)$
 /image-fa013d.php?zc=$1w=$2h=$3src=../uploads/images/$4;
 expires 1w;
 }

 Kind regards,

 Karl



 Nope, since the request actually processed by your PHP handler not at that
 location.
 Since it's an fcgi, pretty sure caching directives only work with
 fastcgi_cache:


 http://nginx.org/en/docs/http/ngx_http_fastcgi_module.html#fastcgi_cache_valid





 On Tue, Mar 17, 2015 at 2:02 PM, Nurahmadie Nurahmadie 
 nurahma...@gmail.com wrote:

 That's because the latter regex location takes precedence over the
 /static one.
 You should first decide if that regex location should also includes
 /static prefix or not.
 If it's a yes, then you should also add the same rewrite-rule inside
 your regex location, if it's a not, you can turn your /static location to
 also use regex like this

 location ~ ^/static/ {
 # rewrite here...
 }

 So nginx will take a look at that location first when you request for
 /static/* urls.

 Another way is to use `try_files`, but then you should probably create
 another (internal) location block to do the rewrite.


 On Wed, Mar 18, 2015 at 2:49 AM, Karl Johnson karljohnson...@gmail.com
 wrote:

 Hello,

 I host a website based on Laravel with Nginx 1.6.2 + PHP-FPM 5.6. Most
 images on the website are in /static folder and are served to visitors with
 a PHP file (see /static location).

 I want to add a 30 days expire on all images of this vhost. However,
 when I add the location ~* \.(?:image)$ { rule to add expire, the rewrite
 for images in /static doesn't work anymore. Nginx reports file not found
 for all images in /static.

 Any idea how to make it works?

 Vhost configuration below:

 server {
 listen 80;
 server_name www.website.com;
 root /home/www/website.com/public_html/public;
 access_log /var/log/nginx/website.com-access_log;
 error_log /var/log/nginx/website.com-error_log warn;

 location /static {
 rewrite
 ^/static/images/([0-9])\-([0-9]+)x([0-9]+)/(.*)$
 /image-f7ec13d.php?zc=$1w=$2h=$3src=../uploads/images/$4;
 }

 ## not working, break the rewrite images above
 #
 #   location ~*
 \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc|woff)$ {
 #expires 30d;
 #add_header Cache-Control public;
 #   }

 include conf.d/custom/restrictions.conf;
 include conf.d/custom/pagespeed.conf;
 include conf.d/custom/fpm-laravel.conf;

 pagespeed DisableFilters combine_css;
 }


 Rewrite not working after adding the location for all images expire:

 2015/03/17 13:46:12 [error] 11792#0: *12217 openat() /home/www/
 website.com/public/static/images/0-0x0/2015/03/2015-03-10-media-fr.jpg
 failed (2: No such file or directory)



 Regards,

 Karl

 ___
 nginx mailing list
 nginx@nginx.org
 http://mailman.nginx.org/mailman/listinfo/nginx




 --
 regards,
 Nurahmadie
 --

 ___
 nginx mailing list
 nginx@nginx.org
 http://mailman.nginx.org/mailman/listinfo/nginx



 ___
 nginx mailing list
 nginx@nginx.org
 http://mailman.nginx.org/mailman/listinfo/nginx




 --
 regards,
 Nurahmadie
 --

 ___
 nginx mailing list
 nginx@nginx.org
 http://mailman.nginx.org/mailman/listinfo/nginx

___
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx

Re: Adding expires on all images break nginx rewrite

2015-03-17 Thread Karl Johnson
Thanks for the reply Nurahmadie.

I changed the location to ~ ^/static/ and the rewrite works again. I've
added a expires 1w; in this location to add an expire on all images in
/static but it doesn't seem to apply, images give 200 OK and never cache.
Is it the right way to do it?

location ~ ^/static/ {
rewrite ^/static/images/([0-9])\-([0-9]+)x([0-9]+)/(.*)$
/image-fa013d.php?zc=$1w=$2h=$3src=../uploads/images/$4;
expires 1w;
}

Kind regards,

Karl



On Tue, Mar 17, 2015 at 2:02 PM, Nurahmadie Nurahmadie nurahma...@gmail.com
 wrote:

 That's because the latter regex location takes precedence over the /static
 one.
 You should first decide if that regex location should also includes
 /static prefix or not.
 If it's a yes, then you should also add the same rewrite-rule inside your
 regex location, if it's a not, you can turn your /static location to also
 use regex like this

 location ~ ^/static/ {
 # rewrite here...
 }

 So nginx will take a look at that location first when you request for
 /static/* urls.

 Another way is to use `try_files`, but then you should probably create
 another (internal) location block to do the rewrite.


 On Wed, Mar 18, 2015 at 2:49 AM, Karl Johnson karljohnson...@gmail.com
 wrote:

 Hello,

 I host a website based on Laravel with Nginx 1.6.2 + PHP-FPM 5.6. Most
 images on the website are in /static folder and are served to visitors with
 a PHP file (see /static location).

 I want to add a 30 days expire on all images of this vhost. However, when
 I add the location ~* \.(?:image)$ { rule to add expire, the rewrite for
 images in /static doesn't work anymore. Nginx reports file not found for
 all images in /static.

 Any idea how to make it works?

 Vhost configuration below:

 server {
 listen 80;
 server_name www.website.com;
 root /home/www/website.com/public_html/public;
 access_log /var/log/nginx/website.com-access_log;
 error_log /var/log/nginx/website.com-error_log warn;

 location /static {
 rewrite ^/static/images/([0-9])\-([0-9]+)x([0-9]+)/(.*)$
 /image-f7ec13d.php?zc=$1w=$2h=$3src=../uploads/images/$4;
 }

 ## not working, break the rewrite images above
 #
 #   location ~*
 \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc|woff)$ {
 #expires 30d;
 #add_header Cache-Control public;
 #   }

 include conf.d/custom/restrictions.conf;
 include conf.d/custom/pagespeed.conf;
 include conf.d/custom/fpm-laravel.conf;

 pagespeed DisableFilters combine_css;
 }


 Rewrite not working after adding the location for all images expire:

 2015/03/17 13:46:12 [error] 11792#0: *12217 openat() /home/www/
 website.com/public/static/images/0-0x0/2015/03/2015-03-10-media-fr.jpg
 failed (2: No such file or directory)



 Regards,

 Karl

 ___
 nginx mailing list
 nginx@nginx.org
 http://mailman.nginx.org/mailman/listinfo/nginx




 --
 regards,
 Nurahmadie
 --

 ___
 nginx mailing list
 nginx@nginx.org
 http://mailman.nginx.org/mailman/listinfo/nginx

___
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx

Adding expires on all images break nginx rewrite

2015-03-17 Thread Karl Johnson
Hello,

I host a website based on Laravel with Nginx 1.6.2 + PHP-FPM 5.6. Most
images on the website are in /static folder and are served to visitors with
a PHP file (see /static location).

I want to add a 30 days expire on all images of this vhost. However, when I
add the location ~* \.(?:image)$ { rule to add expire, the rewrite for
images in /static doesn't work anymore. Nginx reports file not found for
all images in /static.

Any idea how to make it works?

Vhost configuration below:

server {
listen 80;
server_name www.website.com;
root /home/www/website.com/public_html/public;
access_log /var/log/nginx/website.com-access_log;
error_log /var/log/nginx/website.com-error_log warn;

location /static {
rewrite ^/static/images/([0-9])\-([0-9]+)x([0-9]+)/(.*)$
/image-f7ec13d.php?zc=$1w=$2h=$3src=../uploads/images/$4;
}

## not working, break the rewrite images above
#
#   location ~*
\.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc|woff)$ {
#expires 30d;
#add_header Cache-Control public;
#   }

include conf.d/custom/restrictions.conf;
include conf.d/custom/pagespeed.conf;
include conf.d/custom/fpm-laravel.conf;

pagespeed DisableFilters combine_css;
}


Rewrite not working after adding the location for all images expire:

2015/03/17 13:46:12 [error] 11792#0: *12217 openat() /home/www/
website.com/public/static/images/0-0x0/2015/03/2015-03-10-media-fr.jpg
failed (2: No such file or directory)



Regards,

Karl
___
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx