By NizarKhalifa
Hi,
Actually i have one site and two servers in Nginx conf file.
The first:
server {
listen 80 default;
server_name localhost;
access_log off;
rewrite ^ https://$http_host$request_uri? permanent; # force redirect http to https
}
The second
server {
listen 443 ssl;
server_name localhost;
ssl on;
ssl_certificate /etc/nginx/certificates/test.crt;
ssl_certificate_key /etc/nginx/certificates/test.key;
access_log /home/collecte.log;
root /var/www;
location / {
index index.php index.html index.htm;
}
location ~ \.php$ {
if ( $request ~* myString){
access_log off;
# access_log /home/collecte2.log;
}
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www$fastcgi_script_name;
include fastcgi_params;
}
location ~* \.(ico|css|js|gif|jpg|jpeg|png)$ {
expires 1d;
add_header Pragma public;
add_header Cache-Control "public";
}
}
The idea is to separate requests in two files. Like in the second server i disabled the log for same requests and i want to save them in another access_log file.
I tried access_log /home/collecte2.log; but it doesn’t work.
Does anyone have any idea if i can duplicate the server with same configuration or with a different server name? How can i create two log files that receive a specific requests
Best regards, Nizar.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
After updating your configuration files did you restart your nginx service so the change could take effect? service nginx restart
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Scale up as you grow — whether you're running one virtual machine or ten thousand.

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.
