nginx problem list

Keywords: Nginx vim SSL Permission denied

nginx problem list

Installation and Startup of nginx

Installation: reference link - Novice bird tutorial

find / -name nginx
ps -ef|grep nginx

Configure nginx startup self-start:

vim /etc/rc.d/rc.local

touch /var/lock/subsys/local
/usr/bin/fdfs_tracked /etc/fdfs/tracker.conf restart
/usr/bin/fdfs_storaged /etc/fdfs/storage.conf restart

Open log for nginx

I have a configuration like this
location /test {
alias /home/lmj/;
index test.html;

View error log:
vim /usr/local/nginx/logs/error.log
"/home/lmj/" failed (13: Permission denied)
Open access to resources
chmod 777 /home/lmj chmod 777 /home/lmj/test.html
Specify the installation directory for nginx at installation time
./configure --prefix=/xx/xx

–with-debug enable debug logging
–modules-path=PATH set modules path
–with-select_module enable select module
–without-select_module disable select module

nginx configuration syntax

Configuration files consist of instructions and instructions
Each instruction ends with;
Incude allows multiple profiles to be combined
Use $Use variables

  • Localization is a url expression

  • nginx command line
    -s Signals the system to request stop/restart or reload
    -t Detect profile.
    -c is the specified profile

nginx configuration: role of server_name

nginx log level

debug > info > notice > warn > error > crit > alert > emerg

access_log logs/access.log main;

log_format main

Configure the output format for logs

Resolve restart issues

vim /usr/local/nginx/conf/nginx.conf

mkdir /usr/local/nginx/logs
cp /var/run/nginx/ /usr/local/nginx/logs/

nginx -c /alidata/server/nginx/conf/nginx.conf

/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

How to view compilation options when installing Nginx

View compilation options when installing Nginx through the /opt/nginx/sbin/nginx-V command

nginx reverse proxy and load balancing configuration

    upstream testRedisson{
        server weight=3;
        server weight=3;
        server weight=3;

    server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

          location /testRedisson {
             proxy_pass http://testRedisson;
             index  index.html  index.htm;
         location /group1/M00/ {


Browser access
With load balancing, requests are randomly assigned to ports 8082, 8083, 8084, with the following forwarded paths:

nginx Configuration Annotation Version

#Configure User, Maximum Connections, Log Level - Main Module Command
#user  nobody;  #Specify users and user groups for the Nginx Worker process to run
worker_processes  1;     #Specifies the number of nginx processes, typically consuming an average of 10M~12M of memory per Nginx process.It is recommended that the number of CPU s specified be the same.

#error_log  logs/error.log;            #Define the global error log file debug>info>notice>warn>error
#error_log  logs/error.log  notice;
error_log  logs/error.log  info;       #This is a relative location with nginx's installation path as a reference.My in/usr/local/nginx/logs/error.log

pid        logs/;          #Specify the storage location for nginx process number (pid) files

events {
    worker_connections  1024;    #The maximum number of connections for nginx is 1024 - event directives

http {
    include       mime.types;      #Can be used to include additional configuration files
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';
					  #Used to specify the output format of the Nginx log.main is the name of this log output format and can be referenced in the access_log directive below.

     access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    gzip  on;    #Turn on GZIP compression, real-time compression of output data streams, to speed up front-end and back-end data transmission
	#server {
		#	listen 80;   
		#	server_name;       #Specify an IP address or domain name, with spaces separating multiple domain names
		#	charset utf8;                          #Set the default encoding format for Web pages
		#	access_log logs/ main;   #Specifies the access log storage path for this virtual host, main is a format variable
					 #location / {   
                     # alias test/          ## Equivalent to location/test/{}					 
					 #	index index.html index.htm index.php;     #index is used to set the default home page address for access
					 #	root /wwwroot/              #The root directive specifies the root directory of the Web page for the virtual host and can be relative/absolute
					 #   autoindex on;        #Tree structure display site directory
					  # location /group1/M00/ {
					  #    ngx_fastdfs_module;          #For integrating fastdfs distributed file servers
					  # }
		server {
			listen 80;   
			server_name localhost
			charset utf8;                         
			access_log logs/test.log main; 
			   location / {                                 
				 root html;                                 
				 index index.html;
			   location /test { 
				  alias	/home/lmj/;                                 
				  index test.html;
        # Page redirection encountered 500 requests
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #location ~ /\.ht {
        #    deny  all;

    #Configure Load Balancing
	#ip_hash;  # FairAssign requests/ url_hash based on the response time of the back-end server: Assign requests/ip_hash based on the hash result of accessing the url: Assign/poll per request based on the hash result of accessing the IP (default): Assign each request to a different back-end server one by one in chronological order
	#server;   #You can set the status of each back-end server in load balancing scheduling
	#server down; #Indicates that the current server is temporarily not participating in load balancing/backup: Reserved backup machine/max_fails: Number of times requests are allowed to fail, defaulting to 1/fail_timeout: Time to pause the service after experiencing max_fails failures
	#server max_fails=3 fail_timeout=20s;
	#Load balancing and direction proxy are often implemented in a combination
  #	server {
       # listen       80;
       # server_name  localhost;

      #  location /hi {
    #        proxy_pass;
    #    }
   # }
   # Accessing http://localhost/hi, the proxy module forwards the request to port 8001 of
    #Configure ssl certificates, which are actually https certificates
    # HTTPS server
    #server {
    #    listen       443 ssl;        
    #    server_name  localhost;

    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_cache    shared:SSL:1m;
    #    ssl_session_timeout  5m;

    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers  on;

    #    location / {
    #        Root html; the root directory is the unzipped directory of nginx, where is the static resource allowed access under the configuration/path.(Opening static resources to the outside world)
    #        index  index.html index.htm;
    #    }


444 original articles were published. 84 were praised. 190,000 visits+
His message board follow

Posted by POG1 on Thu, 30 Jan 2020 17:06:05 -0800