Home >Operation and Maintenance >Nginx >How to implement Nginx domain name forwarding

How to implement Nginx domain name forwarding

王林
王林forward
2023-05-19 23:43:052028browse

nginx Introduction

nginx ("engine x") is a high-performance web and reverse proxy server developed by Russian programmer igor sysoev , also an imap/pop3/smtp proxy server. In the case of high connection concurrency, nginx is a good alternative to the apache server.

nginx installation

1. Install compilation tools and library files

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

2. Install pcre

自行下载解压源码包
cd 安装目录
./configure 
make && make install//编译安装

3. Install nginx

自行下载解压源码包
cd 安装目录
./configure
make
make install

nginx common commands

### nginx/sbin 目录下 ###

## 启动nginx
./nginx

## 关闭nginx
./nginx -s stop

## 重新加载配置文件
./nginx -s reload

Domain name forwarding configuration

The following is my configuration file. I only configured a simple domain name forwarding function and did not use other nginx functions. nginx is extremely powerful, and domain name forwarding is just the tip 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.

The above is the detailed content of How to implement Nginx domain name forwarding. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete