nginx – two subdomain configuration

The mistake is putting a server block inside a server block, you should close the main server block then open a new one for the sub domains server { server_name example.com; # the rest of the config } server { server_name sub1.example.com; # sub1 config } server { server_name sub2.example.com; # sub2 config }

How to generate a JSON log from nginx?

Finally it looks like we have good way to do this with vanilla nginx without any modules. Just define: log_format json_combined escape=json ‘{‘ ‘”time_local”:”$time_local”,’ ‘”remote_addr”:”$remote_addr”,’ ‘”remote_user”:”$remote_user”,’ ‘”request”:”$request”,’ ‘”status”: “$status”,’ ‘”body_bytes_sent”:”$body_bytes_sent”,’ ‘”request_time”:”$request_time”,’ ‘”http_referrer”:”$http_referer”,’ ‘”http_user_agent”:”$http_user_agent”‘ ‘}’; Note that escape=json was added in nginx 1.11.8. http://nginx.org/en/docs/http/ngx_http_log_module.html#log_format

nginx not listening to port 80

I had this same problem, the solution was that I had not symlinked my siteconf file correctly. Try running vim /etc/nginx/sites-enabled/mysite.com—can you get to it? I was getting “Permission Denied.” If not run: rm /etc/nginx/sites-enabled/mysite.com ln -s /etc/nginx/sites-available/mysite.com /etc/nginx/sites-enabled/mysite.com

Find nginx version?

It seems that your nginx hasn’t been installed correctly. Pay attention to the output of the installation commands: sudo apt-get install nginx To check the nginx version, you can use this command: $ nginx -v nginx version: nginx/0.8.54 $ nginx -V nginx version: nginx/0.8.54 TLS SNI support enabled configure arguments: –conf-path=/etc/nginx/nginx.conf –error-log-path=/var/log/nginx/error.log –http-client-body-temp-path=/var/lib/nginx/body –http-fastcgi-temp-path=/var/lib/nginx/fastcgi –http-log-path=/var/log/nginx/access.log … Read more

Full record url in nginx log

Try adding the $host variable in log_format: log_format main ‘$http_x_forwarded_for – $remote_user [$time_local] “$host” “$request” ‘ ‘$status $body_bytes_sent “$http_referer” ‘ ‘”$http_user_agent” $request_time’; http://wiki.nginx.org/HttpCoreModule#.24host: $host This variable is equal to line Host in the header of request or name of the server processing the request if the Host header is not available. This variable may have … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)