Access_log coming with date and time - squid

I need to use access_log for some automation purpose.
After sometime access_logs are coming with date and time, i want to keep it with the name access_log only.
I have given the name in squid.conf but that is not working for me.
please suggest.

First, check your Squid configuration file and make sure there is no logfile_rotate parameter specified.
Then, check your operating system's logrotate.d folder for a configuration file directing it to rotate Squid's configuration file, and either remove the file completely, or rename it so it has a ".disabled" extension (may not work on all distributions).
On CentOS the logrotate configuration can be found at /etc/logrotate.d/squid.

Related

Nginx - Custom configuration files location

I use Nginx with many domains. Some of these domains have custom configurations. I'm including these files inside the server blocks in the Nginx configurations.
For example:
server {
... some configurations things here...
include /var/somewhere/custom.conf;
etc.. etc..
}
The configuration files of Nginx are inside: /etc/nginx
To try and keep everything in one place and not have my custom configuration files all over the place I would like to place my custom configuration files inside /etc/nginx/some_directory
Can I create a sub directory inside /etc/nginx without it causing any issues with Nginx itself? I want to create /etc/nginx/some_directory/ and place my many custom configuration files inside it and include them.
I'm specifically asking this question because I don't want to break something on my production server.
If nginx doesn't know about a directory, it'll not touch it. You can verify that by greping against such pattern in nginx's codebase.
However, messing with a foreign folder structure might cause problems with permissions and ownership of the files, therefore either just use a pre-defined folders nginx prepared for you (/etc/nginx/sites-enabled and /etc/nginx/sites-available) which you can use with symlinks such as nginx itself does
# ls /etc/nginx/sites-enabled
default -> /etc/nginx/sites-available/default
# ls /etc/nginx/sites-available
default
otherwise you're getting into a situation what C/C++ programmers call an undefined behavior and there's no guarantee that what works now will work in the future / nginx doesn't change as well as the distro maintainers might mess with the folder structure and permissions for the packages in distro package manager.
Example:
Nginx might verify the full /etc/nginx tree's permissions and owners - if your folders/files don't match it might cause a warning or crash even. If it's installed by a package manager, it might cause issues when removing the package itself e.g. if the package manager attempts to remove only a known list of folders + afterwards the parent i.e. /etc/nginx by rmdir or similar. Situations you don't really want to get into and debug when you can use allowed folders or symlinks or your own folders that are not bound to an application or behavior except the one you define.

How to conf nginx worker_connections with cf buildpack staticfile

I'm using the CF buildpack staticfile and added the Custom Location feature to conf my Special Location (documented here).
Now I want to increase the number of worker_processes and/or worker_connections used by Nginx. This is possible adding a nginx.conf file but this is deprecated and I would like to stick with the new pattern to only specify the conf that differs from the defaults.
Is there any way to specify worker_connections in a conf file that will be use when building the nginx.conf?
You cannot set worker_processes or work_connections in this manner for two reasons.
These two properties cannot be set in a location block (see https://nginx.org/en/docs/ngx_core_module.html#worker_processes and https://nginx.org/en/docs/ngx_core_module.html#worker_connections).
The configuration mechanism you're using will include your custom file into the single location block that is in the generated config file.
Thus it's not possible to set those two values using this manner, because neither can be set in a location block and that is the only place you can inject configuration, the location block using this configuration mechanism.
If you need to customize these settings, I would suggest that you use the nginx-buildpack instead and just provide a full custom nginx.conf file.
If you like, you can run once using the staticfile buildpack, cf ssh into the container, copy out the generated config file for your app, then switch to the nginx-buildpack and use the copied config file. That will give you a base configuration file, you can then edit as you need and get something similar.

Nginx: How to set environment variable in server block

Simply, I want to achieve same thing of apache vhosts: Set Application_ENV via virtual host config and read this in PHP for nginx. How to do that?
One way to do it is use fastcgi_param as answered here and here.
I prefered another method. Since I'm using GIT as my VCS:
I created a file in the root of my project named it "env.conf",
which contains only 1 string ("production", "development", etc) which is the environment name
Ignored this file in .gitignore.
Read the file and check the value as the first thing in my application starting point.

nginx default configuration files

What does it mean when I see both "nginx.conf" and "nginx.conf.default" configuration files? I also see "fastcgi.conf" and "fastcgi.conf.default" and "fastcgi.params" and "fastcgi.params.default" etc, in the same folder.
Does ".conf.default" get applied and then the ".conf" gets applied on top of it?
Nginx will strictly load the configuration from the .conf files unless you haven't specified otherwise (like using an include rule and include a file with other extension that .conf).
.conf.default files are not applied on top of the .conf files. In fact they are not applied at all.
As far as I know this behaviour appears on debian when you do update nginx (but I might be wrong).

Which nginx-config file is enabled, /etc/nginx/conf.d/default.conf or /etc/nginx/nginx.conf?

There are two config files around, /etc/nginx/conf.d/default.conf
and /etc/nginx/nginx.conf, but which one is enabled?
I am running CentOS6.4 and nginx/1.0.15.
Technically, nginx.conf is all that matters, if you define every thing inside there it would still work, but to keep things organized, they use include, somewhere at the end of nginx.conf you'll see include /etc/nginx/conf.d/* and in some distros you'll also find include /etc/nginx/sites-enabled/* this is a convention to keep things organized, you create your server blocks in that conf.d or sites-enabled folder and it would be included here as if it's written in the nginx.conf file.
Of course you can add your own include lines there normally and create your own new conf folder that would be auto included.
TIP: These files are included in alphabetical order, you need to keep that in mind if you don't specify any server as default_server, because first one would be the default.
the general configuration of nginx is in /etc/nginx/nginx.conf. /etc/nginx/conf.d/default.conf is used to configure the default virtual host. For this you can also use sites-available and sites-enabled.
You can find more details at a blog entry from digital ocean How To Configure The Nginx Web Server On a Virtual Private Server
for save time.
if you just have 1 site to host, nginx.conf is ok. but,
if you have 2~n sites, for more clear config, you should use conf.d fold.

Resources