How to configure Nginx in Linux system

WBOY
Release: 2023-05-12 14:34:19
forward
983 people have browsed it

The reverse proxy service of Nginx server is its most commonly used important function. The reverse proxy service can also derive many important functions of Nginx server related to this.

1. Upgrade the system, uninstall Apache and release Port 80

 Yum update -y
 Yum remove httpd -y
Copy after login

2. Install EPEL repo

 rpm -Uvh http://mirror.ancl.hawaii.edu/linux/epel/6/i386/epel-release-6-8.noarch.rpm
 EPEL repo下载地址:https://fedoraproject.org/wiki/EPEL
Copy after login

3. Install Nginx and set it

Install Nginx

yum install nginx -y Adjust Nginx configuration

 cd /etc/nginx/conf.d
 mv default.conf default.conf.disabled
Copy after login

4. Create Nginx anti-generation configuration file

 cd /etc/nginx/conf.d
 vi yourdomain.com
Copy after login

Paste the following content:

 server {
 listen 80;
 server_name yourdomain.com;
 access_log off;
 error_log off;
 location / {
 proxy_pass http://需要反代的服务器IP/;
 proxy_redirect off;
 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_max_temp_file_size 0;
 client_max_body_size 10m;
 client_body_buffer_size 128k;
 proxy_connect_timeout 90;
 proxy_send_timeout 90;
 proxy_read_timeout 90;
 proxy_buffer_size 4k;
 proxy_buffers 4 32k;
 proxy_busy_buffers_size 64k;
 proxy_temp_file_write_size 64k;
 }
 }
Copy after login

and save it.

5. Set up the firewall to allow access to port 80

 iptables -I INPUT 5 -m state --state NEW -p tcp --dport 80 -j ACCEPT
 service iptables save
 service iptables restart
Copy after login

6. Start Nginx

 service nginx start
Copy after login

The above is the detailed content of How to configure Nginx in Linux system. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:yisu.com
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!