nginx子域名重定向

编辑sftp://[email protected]/etc/nginx/nginx.conf

http {
	include /etc/nginx/mime.types;
	default_type application/octet-stream;
	sendfile on;
	include /etc/nginx/conf.d/*.conf;
	include /etc/nginx/sites-enabled/*;
	
	server{
		listen   80;
   		server_name  huyao.xin;
		location / {
       	 	root /var/lib/jenkins/workspace/test;
       	 	index index.html;
   	 	}
	}

	server{
		listen   80;
   		server_name  www.huyao.xin;    
		location / {
       	 	root /var/lib/jenkins/workspace/test;
       	 	index index.html;
   	 	}
	}
}

添加server, 其中server_name就是域名,root就是重定向的位置


修改好了需要重新启动nginx

命令:

cd ./usr/sbin

./nginx -s reload

你可能感兴趣的:(网络知识)