1、安装nginx
sudo apt-get install nginx sudo service nginx start
2、在/usr/share/nginx下面新建目录mytest,在此目录中新建index.html并在页面上写入一个hello wolrd.
3、删除/etc/nginx/sites-enabled/default;
新建一个文件mytest,文件内容为:
server { listen 80; root /usr/share/nginx/mytest; index index.html index.htm; location /mytest { proxy_pass http://www.baidu.com/; } }
4、访问http://192.168.210.132/mytest,即可以转到百度,注意最后面的/.否则会跳转到search/error.html.
5、直接访问http://192.168.210.132,则显示test
参考链接,非常好的入门教程
参考链接,有讲正则表达式