Nginx has been widely used in production environments compared to Apache's high performance and high concurrency features. If the website originally used Apache, how to quickly use Nginx as a front-end proxy server? To provide services?
Configure with a very simple configuration file. Here, abandon complex switching, and many other factors to consider in the production environment, simply explain the implementation method.
Found Nginx configuration file, usually located in /usr/local/nginx/conf, the name is nginx.conf, in order to test, do not change any configuration of Apache, the Nginx service is on port 81.
Find the server configuration and modify it to the following configuration, where website.com is the domain name of the website
server { listen 81; server_name website.com; #charset koi8-r; #access_log logs/host.access .log main; location /{ proxy_pass http://website.com; #root html; #index index.html index.htm; }
For security, we can first test if the configuration file has a syntax error
Execute the following command to test if the syntax is correct
sudo /usr/local/nginx/sbin/nginx -t
If it is correct, it will display something like the following
nginx: the configuration file /usr/Local/nginx/conf/nginx.conf syntax is oknginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
Why must I test the configuration file correctly?
1. Each line of the Nginx configuration file has a semicolon after it. Many first-time users will forget to add a semicolon. At this point, some inexplicable errors may occur, such as the prompt missing the brackets. 2.Nginx runs When the configuration file is incorrectly loaded, the process may be uncontrolled. Even if you use the stop command, you cannot stop the process. Therefore, you must first test whether the configuration file is correct (ps: If it is really uncontrolled, then you must force the process to kill.) You can use this command to kill the process sudo killall nginx )
After the configuration file is tested correctly, the reload configuration file can make the configuration take effect
sudo /etc/init.d/nginx reload
The configuration file has been successfully loaded. Open the browser and enter the domain name (original website domain name) + port number 81 of the website configured above. For example, the website.com given in the configuration file can use http://website.com:81 Come visit, then set up Nginx as a front-end proxy server. If it is a Chrome browser, you can open the console, find Network, and see if the Response Header of the first file loaded is already Nginx. Here is my screenshot. You can see that the Server line has become Nginx
< Br>
DevOps is the key to more and more large companies and organizations, so it is important for us to r
For the engineers who are developing or operating the Linux platform, it is often necessary to query
on Ubuntu systems Ubuntu is currently the most popular Linux operating system. After the release of
Starting today, I officially entered the development of tiny4412. Today I mainly watched the startu
Linux operating system firewall configuration modification instruction set
Find Out Server CPU Architecture(32 bit or 64 bit) in Linux
Introduction to Linux Cluster Technology
Linux system management and maintenance -bzip2/bunzip2 command
Scientific linux build jdk myeclipse tomcat environment
Create users under Centos5 and add sudo privileges to users
Linux installation tslib-1.4 error and solution
How to use magent to build a memcached cluster
The difference between switching users su and su in Linux Shell
Teach you how to complete Linux network address configuration
What should I do if the ASUS F81se computer installs Ubuntu 12.04?
Computer boot prompt bootmgr is missing how to solve?
Computer Room Collection: How to solve server cooling failure?
Windows 10 Enterprise Edition Free Trial 90 Days August 1st to October 1st End
Win8 Beta screenshot? Microsoft showcases the new Apps screen
Win10 10049 can not start Hyper-V virtual machine reasons and solutions
Why can't the world of Win2003 accept mobile hard disk
Thunder 5.9 common problem solving