How to implement Nginx domain name forwarding

王林
Release: 2023-05-19 23:43:05
forward
1997 people have browsed it

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
Copy after login

2. Install pcre

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

3. Install nginx

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

nginx common commands

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

## 启动nginx
./nginx

## 关闭nginx
./nginx -s stop

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

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; 
    }
  }
}
Copy after login

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!

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!