Nginx 域名转发的实现

这篇文章主要介绍了Nginx 域名转发的实现,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧

Nginx 介绍

Nginx(“engine x”)是一款是由俄罗斯的程序设计师Igor Sysoev所开发高性能的 Web和 反向代理 服务器,也是一个 IMAP/POP3/SMTP 代理服务器。在高连接并发的情况下,Nginx是Apache服务器不错的替代品。

Nginx 安装

1. 安装编译工具及库文件

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

2. 安装 PCRE

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

3. 安装 Nginx

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

Nginx 常用命令

 ### nginx/sbin 目录下 ### ## 启动nginx ./nginx ## 关闭nginx ./nginx -s stop ## 重新加载配置文件 ./nginx -s reload 

域名转发配置

以下是我的配置文件,我仅仅配置了简单的域名转发功能,未使用其他nginx的功能,nginx异常强大,域名转发只是冰山一角。

 ## 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; } } } 

注:别忘了在防火墙上开放端口。

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持html中文网。

以上就是Nginx 域名转发的实现的详细内容,更多请关注0133技术站其它相关文章!

赞(0) 打赏
未经允许不得转载:0133技术站首页 » 服务器