zoukankan      html  css  js  c++  java
  • NGINX域名跳转案列

    1、不同域名不同路径跳转

    nginx实现a.com/teacher域名跳转到b.com/student

    若想实现上面题目的跳转,目前鄙人知道两种方式:

    1.return

    2.proxy_pass

    具体体现在NGINX配置文件如下:

     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 }
    View Code

    显示结果如下:

     

    稍微有点差别的是我并没有在b.com站点下建立一个目录student。

  • 相关阅读:
    [Qt] 事件机制(四)
    shell专题(六):条件判断
    最小生成树
    373. Find K Pairs with Smallest Sums
    gradle代理设置
    266. Palindrome Permutation
    53. Maximum Subarray
    378. Kth Smallest Element in a Sorted Matrix
    240. Search a 2D Matrix II
    74. Search a 2D Matrix
  • 原文地址:https://www.cnblogs.com/dadonggg/p/9058572.html
Copyright © 2011-2022 走看看