nginx related configuration under Linux

WBOY
Release: 2016-08-08 09:30:03
Original
1140 people have browsed it

The company’s server project uses nginx for forwarding and load balancing. During this period, we encountered some problems, especially 404 problems. Let’s talk about my nginx configuration and my solution to 404 problems.

I used two configuration files here

1. nginx.conf configuration file

#user  nobody;
worker_processes 1;



#pid        logs/nginx.pid;
error_log /var/log/nginx/error.log;

events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;
    #access_log logs/access.log  main;
    port_in_redirect off ;
    sendfile        on;
    #tcp_nopush     on;
    #keepalive_timeout  0;
    keepalive_timeout  65;
    #gzip  on;

        # redirect server error pages to the static page /50x.html
        #
        #error_page   500 502 503 504  /50x.html;
        #location = /50x.html {
        #    root   html;
        #}
        include /usr/local/nginx/conf/conf.d/*.conf;


  client_max_body_size 32M;
client_body_buffer_size 1024k;
}
Copy after login
2. Create a new file oa.conf under the conf.d folder
 #upstream t {
  #      server 192.168.7.176:8888;
  #server 127.0.0.1:8888;
 #}

server
{
        listen 80;
        server_name t.test.minisocials.com;

        location / {
            real_ip_header X-Real-IP;
#            proxy_pass http://t;
            proxy_pass http://192.168.7.176:8888;
            access_log  /usr/local/nginx/t.log;
        }
}
Copy after login

Note: upstream is used for load balancing. Since mine is a test server, there is no need for load balancing, so the content is commented.

3. Now let’s talk about the 404 problem

I don’t know who installed the company’s test server nginx. There are two configuration files in nginx.conf, one is in /etc/nginx/nginx.conf and the other is in /usr/local /nginx/conf/nginx.conf, and then I modified the configuration file under the /usr path, which caused the modified content to always report error 404. Later, I used the nginx -t command to make the configuration file take effect. I saw that the effective configuration file path is The configuration file under /etc, I found that the location I changed before was wrong, and then I replaced the configuration file under the /etc path with the configuration file I changed. It was ok and 404 did not appear. I was very confused, haha. . .

4. First contact with nginx, reference materials: nginx Chinese documentation nginx official website

The above introduces the relevant configuration of nginx under Linux, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!