时间:2023-02-10 16:24:01 | 来源:建站知识
时间:2023-02-10 16:24:01 来源:建站知识
企业场景docker run -d -p 53:53/tcp -p 53:53/udp --cap-add=NET_ADMIN --name dns-server andyshinn/dnsmasq:2.75
执行完毕以后,通过命令查看是否创建并运行成功:[root@test125 ~]# docker psCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES38ae71377ef1 andyshinn/dnsmasq:2.75 "dnsmasq -k" 22 hours ago Up About an hour 0.0.0.0:53->53/tcp, 0.0.0.0:53->53/udp dns-server
docker exec -it dns-server /bin/sh
创建代理文件:vi /etc/resolv.dnsmasq
添加内容:nameserver 114.114.114.114nameserver 8.8.8.8
新建本地解析规则配置:vi /etc/dnsmasqhosts
添加解析规则:192.168.1.125 dev.52itstyle.com test.52itstyle.com sit.52itstyle.com
修改dnsmasq配置文件,指定使用上述两个我们自定义的配置文件:vi /etc/dnsmasq.conf
追加下述两个配置resolv-file=/etc/resolv.dnsmasqaddn-hosts=/etc/dnsmasqhosts
退出容器:exit
重启容器:docker restart dns-server
Nginx安装yum install readline-devel pcre-devel openssl-devel -yyum install wget perl gcc -y
下载最新版本:wget https://openresty.org/download/openresty-1.13.6.1.tar.gz
解压:tar -xvf openresty-1.13.6.1.tar.gz
安装配置:./configure
您可以使用下面的命令来编译安装:make && make install
如果您的电脑支持多核 make 工作的特性, 您可以这样编译安装:make && make install -j2
为了方便启动,建立软连接:ln -s /usr/local/openresty/nginx/sbin/nginx /usr/sbin/nginx
在/usr/local/openresty/nginx/conf文件夹下创建vhosts目录,然后依次创建一下文件(演示文件,正式环境中会有多个项目转发)。server{ listen 80; server_name dev.52itstyle.com; proxy_set_header Host $host; location /{ proxy_pass http://192.168.1.170:8080; }}
test.52itstyle.com.conf:server{ listen 80; server_name test.52itstyle.com; proxy_set_header Host $host; location /{ proxy_pass http://192.168.1.180:8080; }}
sit.52itstyle.com.conf:server{ listen 80; server_name sit.52itstyle.com; proxy_set_header Host $host; location /{ proxy_pass http://192.168.1.190:8080; }}
配置文件:vi /usr/local/openresty/nginx/conf/nginx.confworker_processes 2;events { worker_connections 1024;}http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; #导入各个环境 include vhosts/*.conf;}
启动服务:执行 nginx命令即可。关键词:代替,使用,地址,代理