zoukankan      html  css  js  c++  java
  • nginx匹配规则

    原来nginx匹配规则也是,
    只要知道怎么写
    然后动手写规则
    然后进行测试,
    根据网页F12 一个个进行测试 即可成功.
    
    192.168.1.137:3017/lab/workspaces/auto-U 代理成http://192.168.1.137:8092/container/192.168.1.137:3017/lab/workspaces/auto-U
    
    # For more information on configuration, see:
    #   * Official English Documentation: http://nginx.org/en/docs/
    #   * Official Russian Documentation: http://nginx.org/ru/docs/
    
    user nginx;
    worker_processes auto;
    error_log /var/log/nginx/error.log;
    pid /run/nginx.pid;
    
    # Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
    include /usr/share/nginx/modules/*.conf;
    
    events {
        worker_connections 1024;
    }
    
    http {
        log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                          '$status $body_bytes_sent "$http_referer" '
                          '"$http_user_agent" "$http_x_forwarded_for"';
    
        access_log  /var/log/nginx/access.log  main;
    
        sendfile            on;
        tcp_nopush          on;
        tcp_nodelay         on;
        keepalive_timeout   65;
        types_hash_max_size 2048;
    
        include             /etc/nginx/mime.types;
        default_type        application/octet-stream;
        resolver 8.8.8.8;
        # Load modular configuration files from the /etc/nginx/conf.d directory.
        # See http://nginx.org/en/docs/ngx_core_module.html#include
        # for more information.
        include /etc/nginx/conf.d/*.conf;
                server {
                listen 8092;
                server_name localhost;
                client_max_body_size 500M;
    
                # 此处为截取请求地址中bimg4之后的路径,并赋给转发地址
                # 请求地址:http://11.19.1.212:82/bimg4/32.52.62.42:222/DownLoadFile?filename=20180208
                # 内网地址:http://32.52.62.42:222/DownLoadFile?filename=20180208
    
    
                # 容器端口映射
                #location ^~ /container/ {
                location / {
                    if ($request_uri ~* /container/(.*)) {
                        set $bucketid $1;
                    }
                     #echo "url: $bucketid";
                     proxy_pass http://$bucketid;
                    # rewrite ^/(.*)  http://$bucketid;
                 }
                location ~ .*.(js|css)$ { proxy_pass http://127.0.0.1:3017; }
                location ~ /api/  { proxy_pass http://127.0.0.1:3017; }
                location ~ /static/  { proxy_pass http://127.0.0.1:3017; }
                location ~ /metrics { proxy_pass http://127.0.0.1:3017; }
                location ~ /kernelspecs{ proxy_pass http://127.0.0.1:3017; }
                #location ~ /stop_container{ proxy_pass http://127.0.0.1:3017; }
               # location ~ /(lab) { proxy_pass http://127.0.0.1:3017; }
                # http://192.168.1.137:3039/lab/workspaces/107158/?token=jupyterAdmin
                # http://192.168.1.137:8092/container/192.168.1.137:3039/lab/workspaces/107158/?token=jupyterAdmin
    
                    }
    # Settings for a TLS enabled server.
    #
    #    server {
    #        listen       443 ssl http2 default_server;
    #        listen       [::]:443 ssl http2 default_server;
    #        server_name  _;
    #        root         /usr/share/nginx/html;
    #
    #        ssl_certificate "/etc/pki/nginx/server.crt";
    #        ssl_certificate_key "/etc/pki/nginx/private/server.key";
    #        ssl_session_cache shared:SSL:1m;
    #        ssl_session_timeout  10m;
    #        ssl_ciphers HIGH:!aNULL:!MD5;
    #        ssl_prefer_server_ciphers on;
    #
    #        # Load configuration files for the default server block.
    #        include /etc/nginx/default.d/*.conf;
    #
    #        location / {
    #        }
    #
    #        error_page 404 /404.html;
    #            location = /40x.html {
    #        }
    #
    #        error_page 500 502 503 504 /50x.html;
    #            location = /50x.html {
    #        }
    #    }
    
    }
    
  • 相关阅读:
    01--DNS服务器3
    01--DNS服务器2
    装配bean
    实现二级域名
    apache反向代理
    struts拓展restful
    restful是什么
    struts的声明式异常处理
    linux常用命令之压缩打包
    linux常用命令之文件系统
  • 原文地址:https://www.cnblogs.com/sxgaofeng/p/12894503.html
Copyright © 2011-2022 走看看