Nginx 配置反向代理二級目錄到IP地址

一、nginx.conf配置文件內容:javascript

user nobody nobody;
worker_processes     auto;
worker_cpu_affinity  auto;

error_log  /opt/logs/tengine/error.log;
pid        logs/nginx.pid;

#Changes the limit on the maximum number of open files for worker processes
worker_rlimit_nofile 65000;

events {
    use epoll;
    worker_connections  65000;
}

http {

    include       mime.types;
    default_type  application/octet-stream;

    #default log_format combined = main
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent $request_time "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for" '
                      '$upstream_addr $upstream_response_time $upstream_status';
    log_format  ssl  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent $request_time "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for" '
                      '$ssl_protocol $ssl_cipher $upstream_addr '
                      '$upstream_response_time $upstream_status';

    access_log  /opt/logs/tengine/access.log  combined;
    open_log_file_cache max=1000 inactive=30s min_uses=1 valid=1m;
   
    #-------------------------------------------------------------
    server_names_hash_bucket_size 128;
    client_header_buffer_size     32k;
    large_client_header_buffers   8 64k;
    client_max_body_size          200m;
    client_header_timeout     10s;
    client_body_timeout       10s;

    client_body_buffer_size    512k;
    client_body_postpone_size  64k;
    proxy_request_buffering    off;

    sendfile        on;
    tcp_nopush      on;
    tcp_nodelay     on;

    keepalive_timeout  5;
    server_tokens off;
    server_tag    off;
    server_info   off;

    gzip on;
    gzip_min_length  1k;
    gzip_buffers     8 16k;
    gzip_http_version 1.0;
    gzip_comp_level 3;
    gzip_types    text/plain application/x-javascript application/javascript text/css application/xml;
    gzip_vary on;

    #fastcgi_config
    fastcgi_connect_timeout 60;
    fastcgi_read_timeout 300;
    fastcgi_send_timeout 300;
    fastcgi_buffer_size 128k;
    fastcgi_buffers 8 128k;
    fastcgi_busy_buffers_size 512k;
    fastcgi_temp_file_write_size 512k;

    #Proxy_Config
    proxy_connect_timeout 10;
    proxy_read_timeout 30;
    proxy_send_timeout 30;
    proxy_buffer_size 128k;
    proxy_buffers 8 128k;
    proxy_busy_buffers_size 512k;
    proxy_temp_file_write_size 512k;
    proxy_headers_hash_max_size 1024;
    proxy_headers_hash_bucket_size 128;

    proxy_ignore_client_abort on;

    proxy_redirect off;
    proxy_set_header Host $host;
    proxy_set_header Referer $http_referer;
    #proxy_set_header Cookie $http_cookie;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-Proto  $scheme;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_http_version 1.1;
    proxy_set_header Connection "";

    #Nginx_SSL
    ssl_protocols       SSLv3 TLSv1 TLSv1.1 TLSv1.2;        
    ssl_prefer_server_ciphers  on;
    ssl_ciphers "ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS";
    ssl_session_cache shared:SSL:50m;
    ssl_session_timeout 10m;
    ssl_session_tickets off;
    ssl_stapling   on;
    resolver 223.5.5.5 223.6.6.6 valid=300s;
    resolver_timeout 5s; 

    check_shm_size 50M;
    #-----------------------------------------------------------

    #deny ip access
    server {
        listen      80;
        server_name 127.0.0.1;
        location / {
                root            /opt/test/null;
                deny            all;
                }

        location /auto_check_client/ {
                root            /opt/test;
                index           index.php;
                allow           all;

                fastcgi_pass   127.0.0.1:9000;
                fastcgi_index  index.php;
                include        fastcgi.conf;

                }
        }
    include conf.d/*.conf;
}

二、conf.d/目錄下的文件php

訪問v.test.com/pp 跳轉到 http://103.85.190.204,配置以下:
css

#v.test.com 
server {
        listen       80;
        server_name  v.test.com;
        access_log   /opt/logs/tengine/v.test.com.access.log  main;
        error_log    /opt/logs/tengine/v.test.com.error.log   warn;
        root   /opt/case/v.test.com;
        index  index.php index.html index.htm;
        ##配置跳轉的部分
        location  /pp {
                proxy_pass        http://103.85.190.204/;
                proxy_set_header Host $proxy_host;
                proxy_set_header Connection close;
        }
  
        location / {
                rewrite "^/tv/([^-]{0,}-[^-]{0,}-[^-]{0,}-\d{0,}-?[^-]{0,}-?\d{0,}\.html)$" /moviecore/server/list/index.php?ctl=tvList&args=$1 last;
                rewrite "^/dongman/([^-]{0,}-[^-]{0,}-\d{0,}-\d{0,}-[^-]{0,}-\d{0,}\.html)$" /moviecore/server/list/index.php?ctl=dmList&args=$1 last;
                rewrite "^/zongyi/([^-]{0,}-[^-]{0,}-[^-]{0,}-[^-]{0,}-\d{0,}\.html)$" /moviecore/server/list/index.php?ctl=zyList&args=$1 last;
                rewrite "^/dianying/([^-]{0,}-[^-]{0,}-[^-]{0,}-[^-]{0,}-\d{0,}-[^-]{0,}-[^-]{0,}-?\d{0,}.html)$" /moviecore/server/list/index.php?ctl=dyList&args=$1 last;
                rewrite "^/tv/(\d{1,6})\.html$" /moviecore/server/detail/index.php?ctl=newDetail&media=tv&id=$1 last;
                rewrite "^/dongman/(\d{1,6})\.html$" /moviecore/server/detail/index.php?ctl=newDetail&media=dm&id=$1 last;
                rewrite "^/dianying/(\d{1,6}).html$" /moviecore/server/detail/index.php?ctl=dyDetail&id=$1 last;
                rewrite "^/zongyi/(\d{1,6})\.html$" /moviecore/server/detail/index.php?ctl=zyDetail&id=$1 last;
                rewrite "^/dianying/(\d{1,6})/1_0?.html$" /moviecore/server/detail/index.php?ctl=dyDetail&act=play&id=$1&cid=0 last;
                rewrite "^/zongyi/(\d{1,6})/1_0?.html$" /moviecore/server/detail/index.php?ctl=zyDetail&act=play&id=$1&cid=0 last;
                rewrite "^/(dianying|tv|dongman|zongyi)/ping/(\d{1,6})\.html$" /moviecore/server/comment/index.php?id=$2&media=$1 last;
                rewrite "^/tv/(\d{1,6})/2(_(\d{1,4}))?.html$" /moviecore/server/drama/index.php?type=juqing&tv_id=$1&op=generate&num=$3 last;
                rewrite "^/tv/(\d{1,6})/3.html$" /moviecore/server/drama/index.php?type=yanyuan&tv_id=$1&op=generate last;
                rewrite "^/dianying/(\d{1,6})/1.html$" /moviecore/server/detail/index.php?ctl=svDetailV1&id=1&mediaType=dy&mediaId=$1 last;
                rewrite "^/tv/(\d{1,6})/1_0?.html$" /moviecore/server/detail/index.php?ctl=newDetail&act=play&media=tv&id=$1&cid=0 last;
                rewrite "^/dongman/(\d{1,6})/1_0?.html$" /moviecore/server/detail/index.php?ctl=newDetail&act=play&media=dm&id=$1&cid=0 last;
                rewrite "^/zongyi/(\d{1,6})/1.html$" /moviecore/server/detail/index.php?ctl=svDetailV1&id=1&mediaType=zy&mediaId=$1 last;
                rewrite "^/dianying/(\d{1,6})/4.html$" /moviecore/server/detail/index.php?ctl=dyDetail&act=stills&id=$1 last;
                ###0630#
                rewrite "^/dianying/(\d{1,6})/2.html$" /moviecore/server/detail/index.php?ctl=dyDetail&act=word&acttype=plots&id=$1 last;
                rewrite "^/dianying/(\d{1,6})/5.html$" /moviecore/server/detail/index.php?ctl=dyDetail&act=word&acttype=behind_story&id=$1 last;
                rewrite "^/dianying/(\d{1,6})/6.html$" /moviecore/server/detail/index.php?ctl=dyDetail&act=word&acttype=dialogue&id=$1 last;
                #0710
                rewrite "^/(\w+)/dianying.html$" /moviecore/server/list/index.php?ctl=dyList&act=star&name=$1 last;
                rewrite "^/(\w+)/dianshiju.html$" /moviecore/server/list/index.php?ctl=tvList&act=star&name=$1 last;
                ##0719
                rewrite "^/tv/(\d{1,6})/4.html$" /moviecore/server/detail/index.php?ctl=newDetail&media=tv&act=stills&id=$1 last;
                rewrite "^/tv/(\d{1,6})/5.html$" /moviecore/server/detail/index.php?ctl=newDetail&media=tv&act=word&acttype=behind_story&id=$1 last;
                rewrite "^/tv/(\d{1,6})/6.html$" /moviecore/server/detail/index.php?ctl=newDetail&media=tv&act=word&acttype=dialogue&id=$1 last;
                rewrite "^/dongman/(\d{1,6})/4.html$" /moviecore/server/detail/index.php?ctl=newDetail&media=dm&act=stills&id=$1 last;
                rewrite "^/dongman/(\d{1,6})/2.html$" /moviecore/server/detail/index.php?ctl=newDetail&media=dm&act=word&acttype=plots&id=$1 last;
                rewrite "^/dongman/(\d{1,6})/5.html$" /moviecore/server/detail/index.php?ctl=newDetail&media=dm&act=word&acttype=behind_story&id=$1 last;
                rewrite "^/dongman/(\d{1,6})/6.html$" /moviecore/server/detail/index.php?ctl=newDetail&media=dm&act=word&acttype=dialogue&id=$1 last;
                rewrite "^/zongyi/(\d{1,6})/4.html$" /moviecore/server/detail/index.php?ctl=zyDetail&act=stills&id=$1 last;
                rewrite "^/zongyi/(\d{1,6})/2.html$" /moviecore/server/detail/index.php?ctl=zyDetail&act=word&acttype=plots&id=$1 last;
                rewrite "^/zongyi/(\d{1,6})/5.html$" /moviecore/server/detail/index.php?ctl=zyDetail&act=word&acttype=behind_story&id=$1 last;
                rewrite "^/zongyi/(\d{1,6})/6.html$" /moviecore/server/detail/index.php?ctl=zyDetail&act=word&acttype=dialogue&id=$1 last;
                #PC看點啥詳情頁
                rewrite "^/kandian/(\d{1,6}).html$" /moviecore/server/detail/index.php?ctl=kdsPcDetailV1&id=$1 last;
                #2018-05-16 PC端看點啥列表頁
                rewrite "^/kds/(\w+)-(\w+){0,}.html$" /moviecore/server/list/index.php?ctl=kdsList&cate=$1&tag=$2 last;
                #2018-05-16 PC端看點啥短視頻頻道頁
                rewrite "^/kds(/\w+|)(/|)$" /moviecore/server/index/index.php?ctl=kdsPcIndex&identity=$1 last;
                #pc短視頻詳情頁             
                rewrite "^/tv/(\d{1,6})/1.html$" /moviecore/server/detail/index.php?ctl=svDetailV1&id=1&mediaType=tv&mediaId=$1 last;
                rewrite "^/dongman/(\d{1,6})/1.html$" /moviecore/server/detail/index.php?ctl=svDetailV1&id=1&mediaType=dm&mediaId=$1 last;
                rewrite "^/zongyi/(\d{1,6})/1(_(\d{1,10}))?.html$" /moviecore/server/detail/index.php?ctl=svDetailV1&id=$3&mediaType=zy&mediaId=$1 last;
                rewrite "^/dianying/(\d{1,6})/1(_(\d{1,10}))?.html$" /moviecore/server/detail/index.php?ctl=svDetailV1&id=$3&mediaType=dy&mediaId=$1 last;
                rewrite "^/tv/(\d{1,6})/1(_(\d{1,10}))?.html$" /moviecore/server/detail/index.php?ctl=svDetailV1&id=$3&mediaType=tv&mediaId=$1 last;
                rewrite "^/dongman/(\d{1,6})/1(_(\d{1,10}))?.html$" /moviecore/server/detail/index.php?ctl=svDetailV1&id=$3&mediaType=dm&mediaId=$1 last;
                rewrite "^/shipin/(\d{1,10})?.html$" /moviecore/server/detail/index.php?ctl=svDetailV1&id=$1 last;
                #PC看點啥做者頁
                rewrite "^/kds/author/(\d{1,6}).html$" /moviecore/server/kdsPc/index.php?ctl=kdsPcAuthor&id=$1 last;
                #PC看點啥專輯頁
                rewrite "^/kds/album/(\d{1,6}).html$" /moviecore/server/kdsPc/index.php?ctl=kdsPcSpecial&type=album&sid=$1 last;
                #PC看點啥專題頁
                rewrite "^/kds/zt/(\d{1,6}).html$" /moviecore/server/kdsPc/index.php?ctl=kdsPcSpecial&type=zt&sid=$1 last;
                #PC看點啥標籤頁
                rewrite "^/kds/tag/(\d{1,6}).html$" /moviecore/server/kdsPc/index.php?ctl=kdsPcTag&id=$1 last;

        }
      
        location ~ \.php {
                try_files $uri = /moviecore/404show.php;
                fastcgi_pass   127.0.0.1:9000;
                fastcgi_index  index.php;
                include        fastcgi.conf;

        }

        error_page 404 = /moviecore/404show.php;

}

server {
        listen       443;
        server_name  v.test.com;
        access_log   /opt/logs/tengine_ssl/v.test.com.access.log  ssl;
        error_log    /opt/logs/tengine_ssl/v.test.com.error.log   warn;
        root   /opt/case/v.test.com;
        index  index.php index.html index.htm;

        ssl             on;     
        ssl_certificate         /opt/app/tengine/conf/ssl/test.com.pem;
        ssl_certificate_key     /opt/app/tengine/conf/ssl/test.com.key;


        location / {
                rewrite "^/tv/([^-]{0,}-[^-]{0,}-[^-]{0,}-\d{0,}-?[^-]{0,}-?\d{0,}\.html)$" /moviecore/server/list/index.php?ctl=tvList&args=$1 last;
                rewrite "^/dongman/([^-]{0,}-[^-]{0,}-\d{0,}-\d{0,}-[^-]{0,}-\d{0,}\.html)$" /moviecore/server/list/index.php?ctl=dmList&args=$1 last;
                rewrite "^/zongyi/([^-]{0,}-[^-]{0,}-[^-]{0,}-[^-]{0,}-\d{0,}\.html)$" /moviecore/server/list/index.php?ctl=zyList&args=$1 last;
                rewrite "^/dianying/([^-]{0,}-[^-]{0,}-[^-]{0,}-[^-]{0,}-\d{0,}-[^-]{0,}-[^-]{0,}-?\d{0,}.html)$" /moviecore/server/list/index.php?ctl=dyList&args=$1 last;
                rewrite "^/tv/(\d{1,6})\.html$" /moviecore/server/detail/index.php?ctl=newDetail&media=tv&id=$1 last;
                rewrite "^/dongman/(\d{1,6})\.html$" /moviecore/server/detail/index.php?ctl=newDetail&media=dm&id=$1 last;
                rewrite "^/dianying/(\d{1,6}).html$" /moviecore/server/detail/index.php?ctl=dyDetail&id=$1 last;
                rewrite "^/zongyi/(\d{1,6})\.html$" /moviecore/server/detail/index.php?ctl=zyDetail&id=$1 last;
                rewrite "^/dianying/(\d{1,6})/1_0?.html$" /moviecore/server/detail/index.php?ctl=dyDetail&act=play&id=$1&cid=0 last;
                rewrite "^/zongyi/(\d{1,6})/1_0?.html$" /moviecore/server/detail/index.php?ctl=zyDetail&act=play&id=$1&cid=0 last;
                rewrite "^/(dianying|tv|dongman|zongyi)/ping/(\d{1,6})\.html$" /moviecore/server/comment/index.php?id=$2&media=$1 last;
                rewrite "^/tv/(\d{1,6})/2(_(\d{1,4}))?.html$" /moviecore/server/drama/index.php?type=juqing&tv_id=$1&op=generate&num=$3 last;
                rewrite "^/tv/(\d{1,6})/3.html$" /moviecore/server/drama/index.php?type=yanyuan&tv_id=$1&op=generate last;
                rewrite "^/dianying/(\d{1,6})/1.html$" /moviecore/server/detail/index.php?ctl=svDetailV1&id=1&mediaType=dy&mediaId=$1 last;
                rewrite "^/tv/(\d{1,6})/1_0?.html$" /moviecore/server/detail/index.php?ctl=newDetail&act=play&media=tv&id=$1&cid=0 last;
                rewrite "^/dongman/(\d{1,6})/1_0?.html$" /moviecore/server/detail/index.php?ctl=newDetail&act=play&media=dm&id=$1&cid=0 last;
                rewrite "^/zongyi/(\d{1,6})/1.html$" /moviecore/server/detail/index.php?ctl=svDetailV1&id=1&mediaType=zy&mediaId=$1 last;
                rewrite "^/dianying/(\d{1,6})/4.html$" /moviecore/server/detail/index.php?ctl=dyDetail&act=stills&id=$1 last;
                ###0630#
                rewrite "^/dianying/(\d{1,6})/2.html$" /moviecore/server/detail/index.php?ctl=dyDetail&act=word&acttype=plots&id=$1 last;
                rewrite "^/dianying/(\d{1,6})/5.html$" /moviecore/server/detail/index.php?ctl=dyDetail&act=word&acttype=behind_story&id=$1 last;
                rewrite "^/dianying/(\d{1,6})/6.html$" /moviecore/server/detail/index.php?ctl=dyDetail&act=word&acttype=dialogue&id=$1 last;
                #0710
                rewrite "^/(\w+)/dianying.html$" /moviecore/server/list/index.php?ctl=dyList&act=star&name=$1 last;
                rewrite "^/(\w+)/dianshiju.html$" /moviecore/server/list/index.php?ctl=tvList&act=star&name=$1 last;
                ##0719
                rewrite "^/tv/(\d{1,6})/4.html$" /moviecore/server/detail/index.php?ctl=newDetail&media=tv&act=stills&id=$1 last;
                rewrite "^/tv/(\d{1,6})/5.html$" /moviecore/server/detail/index.php?ctl=newDetail&media=tv&act=word&acttype=behind_story&id=$1 last;
                rewrite "^/tv/(\d{1,6})/6.html$" /moviecore/server/detail/index.php?ctl=newDetail&media=tv&act=word&acttype=dialogue&id=$1 last;
                rewrite "^/dongman/(\d{1,6})/4.html$" /moviecore/server/detail/index.php?ctl=newDetail&media=dm&act=stills&id=$1 last;
                rewrite "^/dongman/(\d{1,6})/2.html$" /moviecore/server/detail/index.php?ctl=newDetail&media=dm&act=word&acttype=plots&id=$1 last;
                rewrite "^/dongman/(\d{1,6})/5.html$" /moviecore/server/detail/index.php?ctl=newDetail&media=dm&act=word&acttype=behind_story&id=$1 last;
                rewrite "^/dongman/(\d{1,6})/6.html$" /moviecore/server/detail/index.php?ctl=newDetail&media=dm&act=word&acttype=dialogue&id=$1 last;
                rewrite "^/zongyi/(\d{1,6})/4.html$" /moviecore/server/detail/index.php?ctl=zyDetail&act=stills&id=$1 last;
                rewrite "^/zongyi/(\d{1,6})/2.html$" /moviecore/server/detail/index.php?ctl=zyDetail&act=word&acttype=plots&id=$1 last;
                rewrite "^/zongyi/(\d{1,6})/5.html$" /moviecore/server/detail/index.php?ctl=zyDetail&act=word&acttype=behind_story&id=$1 last;
                rewrite "^/zongyi/(\d{1,6})/6.html$" /moviecore/server/detail/index.php?ctl=zyDetail&act=word&acttype=dialogue&id=$1 last;
                #PC看點啥詳情頁
                rewrite "^/kandian/(\d{1,6}).html$" /moviecore/server/detail/index.php?ctl=kdsPcDetailV1&id=$1 last;
                #2018-05-16 PC端看點啥列表頁
                rewrite "^/kds/(\w+)-(\w+){0,}.html$" /moviecore/server/list/index.php?ctl=kdsList&cate=$1&tag=$2 last;
                #2018-05-16 PC端看點啥短視頻頻道頁
                rewrite "^/kds(/\w+|)(/|)$" /moviecore/server/index/index.php?ctl=kdsPcIndex&identity=$1 last;
                #pc短視頻詳情頁             
                rewrite "^/tv/(\d{1,6})/1.html$" /moviecore/server/detail/index.php?ctl=svDetailV1&id=1&mediaType=tv&mediaId=$1 last;
                rewrite "^/dongman/(\d{1,6})/1.html$" /moviecore/server/detail/index.php?ctl=svDetailV1&id=1&mediaType=dm&mediaId=$1 last;
                rewrite "^/zongyi/(\d{1,6})/1(_(\d{1,10}))?.html$" /moviecore/server/detail/index.php?ctl=svDetailV1&id=$3&mediaType=zy&mediaId=$1 last;
                rewrite "^/dianying/(\d{1,6})/1(_(\d{1,10}))?.html$" /moviecore/server/detail/index.php?ctl=svDetailV1&id=$3&mediaType=dy&mediaId=$1 last;
                rewrite "^/tv/(\d{1,6})/1(_(\d{1,10}))?.html$" /moviecore/server/detail/index.php?ctl=svDetailV1&id=$3&mediaType=tv&mediaId=$1 last;
                rewrite "^/dongman/(\d{1,6})/1(_(\d{1,10}))?.html$" /moviecore/server/detail/index.php?ctl=svDetailV1&id=$3&mediaType=dm&mediaId=$1 last;
                rewrite "^/shipin/(\d{1,10})?.html$" /moviecore/server/detail/index.php?ctl=svDetailV1&id=$1 last;
                #PC看點啥做者頁
                rewrite "^/kds/author/(\d{1,6}).html$" /moviecore/server/kdsPc/index.php?ctl=kdsPcAuthor&id=$1 last;
                #PC看點啥專輯頁
                rewrite "^/kds/album/(\d{1,6}).html$" /moviecore/server/kdsPc/index.php?ctl=kdsPcSpecial&type=album&sid=$1 last;
                #PC看點啥專題頁
                rewrite "^/kds/zt/(\d{1,6}).html$" /moviecore/server/kdsPc/index.php?ctl=kdsPcSpecial&type=zt&sid=$1 last;
                #PC看點啥標籤頁 
                rewrite "^/kds/tag/(\d{1,6}).html$" /moviecore/server/kdsPc/index.php?ctl=kdsPcTag&id=$1 last;
        }

        location ~ \.php {
                try_files $uri = /moviecore/404show.php;
                fastcgi_pass   127.0.0.1:9000;
                fastcgi_index  index.php;
                include        fastcgi.conf;

        }

        error_page 404 = /moviecore/404show.php;

}

三、重啓nginx 進程便可。html

四、nginx 配置proxy_pass代理轉發的時候,加/ 和不加 / 的區別: 若是後面的url加 /,表示絕對根路徑;若是沒有/,表示相對路徑java

一、加/
server_name test.com
location /data/ {
       proxy_pass  http://127.0.0.1/;
}
訪問test.com/data/index.html  會轉發到 http://127.0.0.1/index.html
二、不加/ 
server_name test.com
location /data/ {
       proxy_pass  http://127.0.0.1;
}
訪問test.com/data/index.html  會轉發到http://127.0.0.1/data/index.html
相關文章
相關標籤/搜索