Tag Archives: Nginx company

PHP file download, download failed, nginx open() nginx / fastcgi_ temp/2/10/0000000102“ failed (13: Permission denied)

summary

The file download failed when testing the project

Check the problem

After investigation, it is found that nginx gives error information
open() "/ home/server/nginx/fastcgi_ Temp/2/10/0000000102 "failed (13: permission denied) while reading upstream
nginx prompts us that we do not have permission to operate

and then we enter the directory /home/server/nginx to check fastcgi_ Temp file owner, our name is the root user of root group

we will check the user group and user name of nginx worker again

ps -ef | grep nginx
# We can see that the worker process of nginx is the www user
root 80246 1 0 10:37 ?       00:00:00 nginx: master process /home/server/nginx/sbin/nginx
www 80247 80246 0 10:37 ?       00:00:00 nginx: worker process
root 82877 82840 0 13:56 pts/7 00:00:00 grep --color=auto nginx
# View the group that the www user is in, and the members of the group
groups www
# Ours is the www user of the www user group
www:www

solve the problem

When we download, the nginx worker process is sending the fastcgi_ Temp does not have permission to write to the cache
so we just need to give fastcgi_ The start-up user with the permission of nginx to modify the temp directory WWW: www

chown -R www:www fastcgi_temp/

Neither –kubeconfig nor –master was specified. Using the inClusterConfig. This might not work

When downloading yaml of ingress nginx

wget https://raw.githubusercontent.com/kubernetes/ingress-nginx/nginx-0.30.0/deploy/static/mandatory.yaml -O nginx-ingress-controller.yaml

When deploying ingress nginx, check the pod log and report the following error

Solution:

Add the following hostnetwork: true in yaml, re deploy, or modify the deployment file of pod to deploy the update

Kubernetes hostnetwork: true network
this is a way to define pod network directly
if you use hostnetwork: true to configure the network in pod, the application running in pod can directly see the network interface of the host computer, and all network interfaces on the LAN where the host computer is located can access the application.

After successful deployment, you can log in to the node where the pod is located to view it

netstat -anp |grep LISTEN |grep 80

hostNetwork: true

View log information after deployment

WebSocket failed: Error during WebSocket handshake: Unexpected response code: 400

The front-end and back-end architecture are separated, the development environment is normal, and the errors reported when deploying to the line are as follows:

Websocket error: websocket failed: error during websocket Handshake: unexpected response code: 400

It is obvious that the configuration of nginx does not support the reverse proxy of websocket, so the search and troubleshooting results are as follows:

The most important of them are the three lines

proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";

The first line tells nginx to use HTTP/1.1 communication protocol, which websoket must use. The second and third lines tell nginx to respond to the HTTP upgrade request when it wants to use websocket. Here, HTTP and websocket reverse proxy coexist, just a protocol upgrade

Supplement:

	server {
	        listen       80;
	        server_name  school.godotdotdot.com;
	        charset utf-8;
	        
			proxy_http_version 1.1; 
			proxy_set_header Upgrade $http_upgrade;
			proxy_set_header Connection "upgrade";
	

	        location/{
	            proxy_pass http://127.0.0.1:3000;
	            proxy_set_header Host $host;
	            proxy_set_header X-Real-IP $remote_addr;
	            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
	            proxy_connect_timeout 60;
	           proxy_read_timeout 600;
	           proxy_send_timeout 600;
	        }

	        error_page   500 502 503 504  /50x.html;
	        location = /50x.html {
	            root   html;
	        }
	 }

[Solved] MAC Nginx Error: ginx.pid“ failed (2: No such file or directory)

(base) li@lideMacBook-Pro ~ % nginx -s reload
nginx: [error] open() "/usr/local/var/run/nginx.pid" failed (2: No such file or directory)

The problem is that nginx.pid can’t be found, so there is an error in reload. It’s certain that the nginx service hasn’t started at this time. Start nginx, and then there is PID. This problem is solved.

[Solved] tar (child): bzip2: Cannot exec: No such file or directory tar (child): Error is not recoverable: ex

What should I do if I get an error unpacking?
tar (child): bzip2: Cannot exec: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now

The problem is that the corresponding decompression software bzip2 is not installed
yum install bzip2

Decompress again, success!!!

[Solved] lua error: no resolver defined to resolve

Use the rest.http module to request no resolver defined to resolve, the error log prompts attempt to index local 'resp', and the code is as follows.

local resp, err = httpc:request_uri("http://xxx.com",{method = "GET",keepalive = false}) 
	ngx.say(  err)

Solution: add DNS configuration, and add resolver configuration in conf configuration file. As shown in the figure below

Nginx upload error 413 request entity too large

By default, when using nginx reverse proxy to upload more than 2MB files, an error 413 request entity too large will be reported. To solve this problem, it is very simple to modify the configuration of client_ max_ body_ The size value is enough

Modify nginx.conf

 
 

1 2 #cat /usr/local/nginx-1.7.0/conf/nginx.conf | grep client_ max_ body_ size client_ max_ body_ size 10M;

If you need to upload a larger file, the client_ max_ body_ The size can be changed to a larger value. Here it is changed to 10MB

Restart nginx

 
 

1 # /usr/local/nginx-1.7.0/sbin/nginx -s reload

 

nginx: [warn] conflicting server name “www.yqq.org“ on 0.0.0.0:80, ignored

When implementing nginx redirection, the following warning appears:

[root@lnmp1 conf]# nginx -s reload
nginx: [warn] conflicting server name "www.yqq.org" on 0.0.0.0:80, ignored

reason:

www.yqq.org This domain name appears twice or even many times, resolving the same domain name to different directories. Generally, this error occurs when the configuration file is separated separately.

If you bind server name repeatedly, a warning will appear. However, this warning will not affect the operation of the server
moreover, this duplicate binding means that the nginx service running now is duplicate with the nginx service in the new configuration to be loaded. Therefore, this warning is unnecessary.

In the configuration file, the statement that also uses the domain name is annotated. If the domain name is loaded smoothly again, no warning will appear

nginx: [error] invalid PID number ““ in “/data/nginx/logs/nginx.pid“

After modifying the configuration file, nginx: [error] invalid PID number “” in/data/nginx/logs/nginx. PID “appears during restart. This means that a valid PID (process number) cannot be found in the file/data/nginx/logs/nginx. PID

Solution 1: find the PID of nginx’s main process number, write it into nginx.pid file, and restart nginx

[root@yzil ~]# nginx -s reload
nginx: [error] invalid PID number "" in "/data/nginx/logs/nginx.pid"
[root@yzil ~]# ps aux | grep "nginx: master" | grep -v pts | awk '{print $2;}'
2847
[root@yzil ~]# ps aux | grep "nginx: master" | grep -v pts | awk '{print $2;}' > /data/nginx/logs/nginx.pid
[root@yzil ~]# nginx -s reload
[root@yzil ~]# 

Solution 2: kill the nginx main process and restart nginx

[root@yzil ~]# killall nginx
[root@yzil ~]# nginx

 

Linux yum Error: All mirror URLs are not using ftp

All mirror URLs are not using ftp, http[s] or file

Because the support of centos6 has been officially stopped

To solve this problem, execute the following command:

sed -i "s|enabled=1|enabled=0|g" /etc/yum/pluginconf.d/fastestmirror.conf

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

curl -o /etc/yum.repos.d/CentOS-Base.repo https://www.xmpan.com/Centos-6-Vault-Aliyun.repo

yum clean all

yum makecache

It’s OK

Restart and stop of nginx in Linux service

Case 1: nginx has service

Nginx installed in Linux will register service service by default. You can directly start, stop and restart according to the following operations

service nginx start  # start
service nginx stop  # stop
service nginx restart  # restart

Case 2: the original nginx service is not clear

Find the installation directory of nginx to understand the situation of nginx

# Find Nginx installation information
find/-name nginx

# Go to the nginx sbin directory and restart
. /nginx -s reload

# If you have modified the Nginx configuration, check the configuration with -t
. /nginx -t

# Check to see if it starts
ps aux | grep nginx
# or
ps -ef | grep nginx

Nginx more

Adding prefix to nginx agent of Python flash project
deployment of ngnix + gunicorn + Flash project in Ubuntu environment