In case of php-fpm try: fastcgi_param HTTPS on;
Tag Archives: nginx
504 gateway time-out nginx
proxy_connect_timeout 600;
proxy_send_timeout 600;
proxy_read_timeout 600;
nginx allow only index.php
upstream _php {
server unix:/var/run/php-fpm/php-fpm.sock;
}
server {
server_name 192.168.1.100;
root /path/to/root;
index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
location / { deny all; }
location = / { }
location = /index.php { fastcgi_pass _php; }
location /phpmyadmin/ { }
location ~ ^/phpmyadmin/.*\.php$ { fastcgi_pass _php; }
}
FastCGI sent in stderr: “Primary script unknown” while reading response header from upstream, client
File not found.
Make sure SCRIPT_FILENAME same location like root:
server {
server_name 192.168.1.100;
location / {
root /var/www/html;
location ~* \.php$ {
fastcgi_pass unix:/var/run/php/php.sock;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
}
}
}
nginx start from command line
nginx -g "pid /var/run/nginx.pid; worker_processes `sysctl -n hw.ncpu`;"
use the “listen … ssl” directive instead
# ssl on;
413 Request Entity Too Large
vi /etc/nginx/nginx.conf
client_max_body_size 50M;
client_body_buffer_size 1m;
client_body_timeout 15;
client_header_timeout 15;
acme no root
useradd -m -d /var/lib/acme -s /usr/sbin/nologin acme
chmod 700 /var/lib/acme
mkdir -p /var/www/EXAMPLE.com/.well-known/acme-challenge
chown acme.acme /var/www/EXAMPLE.com/.well-known/acme-challenge
chmod 755 /var/www/EXAMPLE.com/.well-known/acme-challenge
location ~ /.well-known {
allow all;
root /var/www/EXAMPLE.com;
}
visudo
acme ALL=(ALL) NOPASSWD: /usr/sbin/service nginx reload
su - acme -s /bin/bash
export HOME=/var/lib/acme
cd /var/lib/acme
git clone https://github.com/acmesh-official/acme.sh.git
cd acme.sh
./acme.sh --install
cd /var/lib/acme
.acme.sh/acme.sh --issue -d EXAMPLE.com -w /var/www/EXAMPLE.com
./acme.sh --issue -w /var/www/EXAMPLE.com -d EXAMPLE.com -d www.EXAMPLE.com
ssl_certificate /etc/nginx/auth-acme/EXAMPLE.com.crt;
ssl_certificate_key /etc/nginx/auth-acme/EXAMPLE.com.key;
ssl_trusted_certificate /etc/nginx/auth-acme/EXAMPLE.com.ca;
service nginx reload
nginx request time latency
log_format time '$remote_addr - $remote_user [$time_local] '
'"$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent" '
'$request_time $upstream_response_time $pipe';
access_log /var/log/nginx/access.log time;
nginx virtual host allow ip
location /spme_private/ {
allow XX.XX.XX.XX;
deny all;
}
pm.status_path blank nginx
location ~ ^/(status-blabla|ping)$ {
access_log off;
allow 127.0.0.1;
allow XX.XX.XX.XX;
deny all;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME /status-blabla;
fastcgi_pass unix:/var/run/php5-fpm-blabla.sock;
}
# XX.XX.XX.XX is your IP address
nginx repo yum centos
vi /etc/yum.repos.d/nginx.repo
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1
ubuntu latest nginx version
curl http://nginx.org/keys/nginx_signing.key | apt-key add -
echo -e "deb http://nginx.org/packages/mainline/ubuntu/ `lsb_release -cs` nginx\ndeb-src http://nginx.org/packages/mainline/ubuntu/ `lsb_release -cs` nginx" > /etc/apt/sources.list.d/nginx.list
apt-get update
apt-get install nginx
400 Bad Request – Request Header Or Cookie Too Large
server {
...
large_client_header_buffers 4 16k;
...
}
nginx list virtual hosts
find /etc/nginx -type f -print0 | xargs -0 egrep '^(\s|\t)*server_name'