一、不一樣域名不一樣路徑跳轉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