一、不一样域名不一样路径跳转html
nginx实现a.com/teacher域名跳转到b.com/studentnginx
若想实现上面题目的跳转,目前鄙人知道两种方式:app
1.returnide
2.proxy_passspa
具体体如今NGINX配置文件以下:3d
1 [root@dadong b]# cat /etc/nginx/nginx.conf 2 worker_processes 1; 3 events { 4 worker_connections 1024; 5 } 6 http { 7 include mime.types; 8 default_type application/octet-stream; 9 sendfile on; 10 keepalive_timeout 65; 11 server { 12 listen 80; 13 server_name a.com; 14 location /teacher/ { 15 # return http://b.com/index.html; 第一种方法return 16 proxy_pass http://b.com/index.html; 第二种方法 proxy_pass 17 # root html/a; 18 # index index.html index.htm; 19 } 20 error_page 500 502 503 504 /50x.html; 21 location = /50x.html { 22 root html; 23 } 24 } 25 server { 26 listen 80; 27 server_name b.com; 28 location / { 29 root html/b; 30 index index.html index.htm; 31 } 32 error_page 500 502 503 504 /50x.html; 33 location = /50x.html { 34 root html; 35 } 36 } 37 }
显示结果以下:code
稍微有点差异的是我并无在b.com站点下创建一个目录student。server