JAVA和Nginx 教程大全

网站首页 > 精选教程 正文

nginx配置支持ipv6访问 nginx 支持ipv6

wys521 2024-10-15 16:12:51 精选教程 32 ℃ 0 评论

前提,需要nginx支持ipv6模块

现在的新版本都支持,以下在nginx-1.9.12本版测试可用!

非常简单,只需要在*.conf文件中配置同时支持v4 和v6,添加以下两行命令即可

listen 80;
listen [::]:80;
[root@localhost conf.d]# cat nginx.conf 
server {
  listen 80;
  listen [::]:80;
  server_name www.test.cn;
  root   /test/html/;
  index  index.html index.htm;
  location / {
    proxy_pass http://127.0.0.1:19999;
  }
  location /downloads/ {
    alias /root/app/downloads/;
  }
}

server {
  listen 80;
  server_name api.test.cn;
  location / {
    proxy_pass http://127.0.0.1:19999;
  }
  location /downloads/ {
    alias /root/app/downloads/;
  }
}

Tags:

本文暂时没有评论,来添加一个吧(●'◡'●)

欢迎 发表评论:

最近发表
标签列表