nginx如何运行在ipv6上

1.nginx运行在ipv6上需要 --with-ipv6 模块

--with-http_stub_status_module --with-http_ssl_module --with-stream --with-ipv6

2.nginx配置文件设置

server {
 #listen 8080;
  listen [::1]:8080;
  server_name localhost;
  root /www/;
  index index.html;
}

3.重启nginx

[root@localhost ~]# ./nginx-1.20.2/objs/nginx -s reload
nginx: [alert] kill(14017, 1) failed (3: No such process)
[root@localhost ~]# ./nginx-1.20.2/objs/nginx -c /root/nginx-1.20.2/conf/nginx.conf
[root@localhost ~]# ./nginx-1.20.2/objs/nginx -s reload

4.访问测试

[root@localhost ~]#  curl -g -6 http://[::1]:8080
this is test
[root@localhost ~]#  curl -g -6 [::1]:8080
this is test

你可能感兴趣的:(nginx专栏,nginx,服务器,运维,linux)