当前位置: 首页 > news >正文

Nginx 学习之 配置支持 IPV6 地址

目录

  • 搭建并测试
    • 1. 下载 NG 安装包
    • 2. 安装编译工具及库文件
    • 3. 上传并解压安装包
    • 4. 编译
    • 5. 安装
    • 6. 修改配置
    • 7. 启动 NG
    • 8. 查看 IP 地址
    • 9. 测试 IP 地址
      • 9.1. 测试 IPV4 地址
      • 9.2. 测试 IPV6 地址
  • IPV6 测试失败原因
    • 1. curl: [globbing] error: bad range specification after pos 9
    • 2. curl: Failed to connect to 0.0.0.10: Invalid argument

搭建并测试

1. 下载 NG 安装包

点击进入 Nginx 网址,下载安装包
在这里插入图片描述

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

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

3. 上传并解压安装包

// 进入指定目录,ftp 上传压缩包tar -zxvf nginx-1.26.2.tar.gz

4. 编译

./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-ipv6

5. 安装

make && make install

6. 修改配置

# 进入 NG 配置文件夹
cd /usr/local/nginx/conf# 修改 NG 配置文件
vim nginx.conf
http {......server {......listen       80;     	# IPV4listen       [::]:80;	# IPV6......}......
}

7. 启动 NG

# 启动 NG
./nginx # 停止 NG
./nginx -s stop# 重启 NG 
./nginx -s reload

8. 查看 IP 地址

[root@iZf8z6w83m8z8cj3m3lmubZ conf]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00inet 127.0.0.1/8 scope host lovalid_lft forever preferred_lft foreverinet6 ::1/128 scope host valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000link/ether 00:16:3e:0a:74:78 brd ff:ff:ff:ff:ff:ffinet 172.18.133.39/20 brd 172.18.143.255 scope global dynamic eth0valid_lft 315340442sec preferred_lft 315340442secinet6 2408:4008:1105:4901:b3f7:6c00:f1d7:e412/64 scope global valid_lft forever preferred_lft forever

9. 测试 IP 地址

9.1. 测试 IPV4 地址

[root@iZf8z6w83m8z8cj3m3lmubZ conf]# curl 172.18.133.39:80
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
html { color-scheme: light dark; }
body { width: 35em; margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif; }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p><p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p><p><em>Thank you for using nginx.</em></p>
</body>
</html>

9.2. 测试 IPV6 地址

[root@iZf8z6w83m8z8cj3m3lmubZ conf]# curl -6 -g http://[2408:4008:1105:4901:b3f7:6c00:f1d7:e412]:80
[root@iZf8z6w83m8z8cj3m3lmubZ conf]# curl http://2408:4008:1105:4901:b3f7:6c00:f1d7:e412:80
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
html { color-scheme: light dark; }
body { width: 35em; margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif; }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p><p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p><p><em>Thank you for using nginx.</em></p>
</body>
</html>

IPV6 测试失败原因

1. curl: [globbing] error: bad range specification after pos 9

IPV6 地址中含有 : 等符号,可能在解析时报错,需要使用 []IPV6 地址包起来,避免解析报错。

# 错误写法
curl http://[2408:4008:1105:4901:b3f7:6c00:f1d7:e412]curl http://[2408:4008:1105:4901:b3f7:6c00:f1d7:e412:80]

2. curl: Failed to connect to 0.0.0.10: Invalid argument

原因存在多种,我遇到是一个比较奇葩的原因。在阿里云和腾讯云中,curl 指定的 IPV6 地址必须与控制台分配的 IPV6 地址一致,自己手动配置的不行。

http://www.lryc.cn/news/428315.html

相关文章:

  • springboot+伊犁地区游客小助手-小程序—计算机毕业设计源码无偿分享需要私信20888
  • 提升工作效率的五大神器
  • 想投资现货黄金?在TMGM开户需要多少钱?
  • “零拷贝”
  • [ABC367C] Enumerate Sequences 题解
  • C语言 | Leetcode C语言题解之第336题回文对
  • 【SQL】仅出现一次的最大数据
  • MySQL 数据类型详解及SQL语言分类-DDL篇
  • Leet Code 128-最长连续序列【Java】【哈希法】
  • 网络协议(概念版)
  • Pulsar官方文档学习笔记——消息机制
  • PyTorch--残差网络(ResNet)在CIFAR-10数据集进行图像分类
  • ETAS工具链自动化实战指南<一>
  • 疫情期间我面试了13家企业软件测试岗位,一些面试题整理
  • PINCE——Linux 原生游戏内存修改器,一款替代 Cheat Engine 的强大游戏修改器,Linux 游戏玩家必备神器!
  • 为IntelliJ IDEA安装插件
  • ES6 Promise
  • html+css 实现hover 凹陷按钮
  • 什么是负载均衡?负载均衡器如何运作?
  • (Arxiv-2023)潜在一致性模型:通过少步推理合成高分辨率图像
  • Unity与UE,哪种游戏引擎适合你?
  • 这五本大模型书籍,把大模型讲的非常详细,收藏我这一篇就够了
  • 伊朗通过 ChatGPT 试图影响美国大选, OpenAI 封禁多个账户|TodayAI
  • windows系统如何走后面之windows系统隐藏账户
  • Elasticsearch(ES)(版本7.x)数据更新后刷新策略RefreshPolicy
  • 【运维】从一个git库迁移到另一个库
  • and design vue表格列宽度拖拽,vue-draggable-resizable插件使用
  • 使用hexo搭建个人博客
  • java geotool构建地理点线面
  • C# 中 Grpc服务端调用客户端方法