Implementation of Nginx domain name forwarding

  • 2020-05-17 07:48:23
  • OfStack

Nginx introduction

Nginx (" engine x ") is a high-performance Web and reverse proxy server developed by Russian programmer Igor Sysoev, and also an IMAP/POP3 / SMTP proxy server. In the case of high connection concurrency, Nginx is a good alternative to Apache servers.

Nginx installation

1. Install the compiler and library files


yum -y install make zlib zlib-devel gcc-c++ libtool openssl openssl-devel

2. Install PCRE


 Download and unzip the source package yourself 
cd  The installation directory 
./configure 
make && make install// Compile the installation 

3. Install Nginx


 Download and unzip the source package yourself 
cd  The installation directory 
./configure
make
make install

Nginx common commands


### nginx/sbin  directory  ###

##  Start the nginx
./nginx

##  Shut down nginx
./nginx -s stop

##  Reload the configuration file 
./nginx -s reload

Domain name forwarding configuration

The following is my configuration file. I only configured the simple function of domain name forwarding, and did not use other functions of nginx. nginx is extremely powerful, and domain name forwarding is only one part of the iceberg.


## nginx/conf/nginx.conf

worker_processes 1;

events {
  worker_connections 1024;
}


http {
  include    mime.types;
  default_type application/octet-stream;

  sendfile    on;

  server {
    listen    80;
    server_name www.fbm.com;
    location / {
      root  html;
      index index.html index.htm;
      proxy_pass http://localhost:8080;
    }
  }
  server {
    listen 80;
    server_name fmp.hzfh.com;
    location / {
      proxy_pass http://fmp.hzfh.com; 
    }
  }
}

Note: don't forget to open ports on the firewall.


Related articles: