nginx 设置ip地址访问,但是设置域名访问不了 | 您所在的位置:网站首页 › 显示域名不存在怎么回事呢 › nginx 设置ip地址访问,但是设置域名访问不了 |
一、导语
在Nginx的设置过程中,ip地址能正常访问的,但是把ip地址转换成域名,就访问不了了,这个是怎么回事呢?今天来探讨一下 二、设置ip地址做负载均衡2.1、server端 server { listen 80; server_name 192.168.1.1; #设置为ip地址 #charset koi8-r; #access_log logs/host.access.log main; location / { proxy_read_timeout 1200; proxy_send_timeout 1200; proxy_connect_timeout 1200; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_redirect off; proxy_pass http://192.168.1.1/; } }2.2、upstream端 upstream 192.168.1.1{ #tomcat1002 server 192.168.1.1:8081 weight=50; #tomcat1001 server 192.168.1.1:8080 weight=50; }然后再Nginx -t 测试一下看能是否访问 [root@VM_0_3_centos server]# nginx -t nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful 三、ip地址能访问,但是域名访问不了在客户端也做了ping了,域名指向命名是ip地址就是访问不了,原来,Nginx优先解析自己的Nginx.conf配置文件,所以先解析自己的,自己的配置文件如下: 所以我们把这部分删掉,在include server/* 自己的配置文件
|
CopyRight 2018-2019 实验室设备网 版权所有 |