nginx 公安內網 跳轉與重定向,try_files 試驗


#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


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

    #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  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;
    
    server {
    listen       8081;
    server_name  localhost;

    location /{
            root   /home/dev/socialDeclareFront/dist;
            index  index.html index.htm;
        }

    location /ask/if/gotoindex.do {
            proxy_redirect off;
            proxy_set_header Host $host;
            proxy_set_header X-Real_Ip $remote_addr;
            proxy_set_header X-forworded-For $remote_addr;
            proxy_pass http://127.0.0.1:6720/socialDeclare/extranet/apply/gotoIndex/;
        }

    
    }

    server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

     location /{
            root   /home/dev/socialDeclareFront/dist;
            index  index.html index.htm;
        }
    #location /shsb_web/{
        #    root   /home/dev/socialDeclareFront/dist/shsb_web;
        #    index  index.html index.htm;
        #}


        location /ask {
            root   /home/dev/socialDeclareFront/dist/shsb_web;
        index index.html;
            #index  /home/dev/socialDeclareFront/dist/shsb_web/index.html;
        }

    location /socialDeclare/{
        #root  /home/dev/socialDeclareFront/dist/shsb_web;
        proxy_redirect off;
        proxy_set_header Host $host;
        proxy_set_header X-Real_Ip $remote_addr;
        proxy_set_header X-forworded-For $remote_addr;
        proxy_pass http://127.0.0.1:6720/socialDeclare/;
    }

    location /eureka {
            proxy_pass http://172.21.29.13:10301/;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }

    location /ask1/if/ {
            proxy_redirect off;
            proxy_set_header Host $host;
            proxy_set_header X-Real_Ip $remote_addr;
            proxy_set_header X-forworded-For $remote_addr;
            proxy_pass http://127.0.0.1:6720/socialDeclare/extranet/apply/;


        }

    location /gotoindex {
            proxy_redirect off;
            proxy_set_header Host $host;
            proxy_set_header X-Real_Ip $remote_addr;
            proxy_set_header X-forworded-For $remote_addr;
            proxy_pass http://172.21.29.13/shsb_web/;
        }

    location /ask/if/gotoindex.do {
            proxy_redirect off;
            proxy_set_header Host $host;
            proxy_set_header X-Real_Ip $remote_addr;
            proxy_set_header X-forworded-For $remote_addr;
            proxy_pass http://127.0.0.1:6720/socialDeclare/extranet/apply/gotoIndex/;
        }
    

    #location ~* gotoindex\.do$ {
            #rewrite ^(.*)  http://113.104.0.233:10006/shsb_web/; 
        
#        proxy_set_header Host $host;
#            proxy_set_header X-Real_Ip $remote_addr;
            #proxy_set_header X-forworded-For $remote_addr;
            #proxy_pass http://127.0.0.1/shsb_web/;

        #   root   /home/dev/socialDeclareFront/dist/shsb_web/;
          #  index  index.html index.htm;
        #proxy_redirect off;
            #proxy_set_header Host $host;
           # proxy_set_header X-Real_Ip $remote_addr;
           # proxy_set_header X-forworded-For $remote_addr;
            #proxy_pass http://127.0.0.1/shsb_web/;
        #}

    #location /shsb_web/static/ {
        #    root   /home/dev/socialDeclareFront/dist/static;
            #index  index.html index.h
        #}
        #error_page  404              /404.html;


        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        #
        #proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }


    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}


    # HTTPS server
    #
    #server {
    #    listen       443;
    #    server_name  localhost;

    #    ssl                  on;
    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_timeout  5m;

    #    ssl_protocols  SSLv2 SSLv3 TLSv1;
    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers   on;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}

}
 

 

/////////////////

 server {
    listen       8081;
    server_name  localhost;
    
    #rewrite ^/shsb_web/(.*) http://113.104.0.233:10005/shsb_web/ permanent;

    location /ask/if/gotoindex.do {
            proxy_redirect off;
            proxy_set_header Host $host;
            proxy_set_header X-Real_Ip $remote_addr;
            proxy_set_header X-forworded-For $remote_addr;
            proxy_pass http://127.0.0.1:6720/socialDeclare/extranet/apply/gotoindex/;
        }
        location /ask/if/zsmsfw.do {
            proxy_redirect off;
            proxy_set_header Host $host;
            proxy_set_header X-Real_Ip $remote_addr;
            proxy_set_header X-forworded-For $remote_addr;
            proxy_pass http://127.0.0.1:6720/socialDeclare/extranet/apply/zsmsfw/;
        }
    
    location /{
            root   /home/dev/socialDeclareFront/dist;
            index  index.html index.htm;
        }
    
    }

    server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

    #rewrite ^/shsb_web/([a-zA-Z]+) http://113.104.0.233:10005/shsb_web/ permanent;    

            #index  /home/dev/socialDeclareFront/dist/shsb_web/index.html;
    #    proxy_pass /home/dev/socialDeclareFront/dist/shsb_web/index.html;
        #}
    

        location /ask {
            root   /home/dev/socialDeclareFront/dist/shsb_web;
        index index.html;
            #index  /home/dev/socialDeclareFront/dist/shsb_web/index.html;
        }

    location /socialDeclare/{
        #root  /home/dev/socialDeclareFront/dist/shsb_web;
        proxy_redirect off;
        proxy_set_header Host $host;
        proxy_set_header X-Real_Ip $remote_addr;
        proxy_set_header X-forworded-For $remote_addr;
        proxy_pass http://127.0.0.1:6720/socialDeclare/;
    }

    location /eureka {
            proxy_pass http://172.21.29.13:10301/;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }

    location /ask1/if/ {
            proxy_redirect off;
            proxy_set_header Host $host;
            proxy_set_header X-Real_Ip $remote_addr;
            proxy_set_header X-forworded-For $remote_addr;
            proxy_pass http://127.0.0.1:6720/socialDeclare/extranet/apply/;


        }

    location /gotoindex {
            proxy_redirect off;
            proxy_set_header Host $host;
            proxy_set_header X-Real_Ip $remote_addr;
            proxy_set_header X-forworded-For $remote_addr;
            proxy_pass http://172.21.29.13/shsb_web/;
        }

    location /ask/if/gotoindex.do {
            proxy_redirect off;
            proxy_set_header Host $host;
            proxy_set_header X-Real_Ip $remote_addr;
            proxy_set_header X-forworded-For $remote_addr;
            proxy_pass http://127.0.0.1:6720/socialDeclare/extranet/apply/gotoindex/;
        }


    # location /shsb_web/ {
        #        try_files '' /shsb_web/index.html;
     #   }
    

        #//注意使用@符號,不然不成功

    location =/shsb_web/homepage {
                try_files '' /shsb_web/index.html;
        }
     location ^~ /shsb_web/declaration {
                try_files '' /shsb_web/index.html;
        }
location /{
            root   /home/dev/socialDeclareFront/dist;
            index  index.html index.htm;
        }

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章