nginx 配置域名转发和进行ip限制
2017-08-02 17:26
555 查看
需求:公司一台服务器上使用tomcat部署了多个网站服务,服务的端口都是6080,根据不同的域名加端口6080可以对相应的服务进行访问,领导新提了个需求,在服务器上部署个nginx 实现域名转发,服务器本身只放开80端口,我们只需要域名就可以进行访问各个网站服务,同时把ip限制放在nginx里面实现。不同的服务可以限制不同的端口。
实现步骤:
一、nginx 服务的安装。
yum install nginx
二、nginx配置
实现步骤:
一、nginx 服务的安装。
yum install nginx
二、nginx配置
user nginx; worker_processes auto; error_log /var/log/nginx/error.log error; pid /var/run/nginx.pid; # Load dynamic modules. See /usr/share/nginx/README.dynamic. include /usr/share/nginx/modules/*.conf; events { worker_connections 1024; } http { log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; include /etc/nginx/mime.types; default_type application/octet-stream; # Load modular configuration files from the /etc/nginx/conf.d directory. # See http://nginx.org/en/docs/ngx_core_module.html#include # for more information. #include /etc/nginx/conf.d/*.conf; server { listen 80; server_name www.fuweichao.com; location / { proxy_pass proxy_redirect default; proxy_set_header Host $host; #这一行如果不设置会把域名转成ip。 deny all; } server { listen 80; server_name www.xxn.com; location / { proxy_pass http://www.xxn.com:9080/; proxy_redirect default; proxy_set_header Host $host; deny all; } }
相关文章推荐
- Nginx 单IP绑定多域名配置 顶级域名重定向到www域名
- nginx多域名同IP同80端口配置
- nginx对ip的访问频率进行限制(limit_req)和对ip连接数(并发量)进行限制(limit_conn)
- 使用Nginx配置同域名同端口下的服务转发
- Nginx设置防止IP及非配置域名访问
- nginx 反向代理做域名转发简单配置
- 一个ip对应多个域名多个ssl证书配置-Nginx实现多域名证书HTTPS
- nginx同一iP多域名配置方法
- Nginx进行域名重写和泛域名解析配置
- nginx servername配置域名网站可以正常登录,servername配置IP+Port却无法正常登录
- nginx配置二:限制来源ip访问
- nginx根据客户端ip进行简单转发(回发)
- nginx同一iP多域名配置方法
- 用Perl写一个读取nginx配置文件到csv,实现域名与IP对应的实用程序
- Nginx配置域名转发实例
- nginx 配置多域名步骤 1个ip配置多个域名
- 配置Nginx支持SSL SNI(一个IP绑定多个证书) 以及Haproxy实现多域名证书
- nginx同一iP多域名配置方法
- nginx中针对目录进行IP限制
- nginx 配置域名转发到其他域名