歡迎您光臨本站 註冊首頁

關於NGINX虛擬目錄的訪問

←手機掃碼閱讀     火星人 @ 2014-03-03 , reply:0

關於NGINX虛擬目錄的訪問

關於NGINX虛擬目錄的訪問



Nginx 負載均衡服務
app1:192.168.100.5:8080
app2:192.168.100.6:8080
nginx:192.168.100.4:1080
為了安全設置需要直接訪問應用http://192.168.100.6:8080這樣訪問不允許,只有手工添加目錄如:http://192.168.100.6:8080/test/abc/autoService.action才能正常訪問,nginx監聽埠為1080,目前想實現訪問http://192.168.100.4:1080,自動添加後面的目錄如http://192.168.100.4:1080/test/abc/autoService.action,我採用了index.html,添加如下內容實現:
<script>
location.href="/test/abc/autoService.action";
</script>
無法成功訪問。
nginx.conf部分配置:
upstream srv {
    server 192.168.100.5:8080;
    server 192.168.100.6:8080;
}
  server {
        listen       1080;
        server_name  _;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location /status/ {
            stub_status on;
            access_log off;
         }

        location / {
           access_log  /home/log/nginx/access_srv.log  main buffer=64k;
            root  /home/www/;
            index  index.html index.htm;
#           if (!-f $request_filename) {
#           rewrite ^/(+).html /$1.action last;
            proxy_pass http://srv;
#            break;
#         }
        }

        location ~ ^/(WEB-INF)/ {
            deny all;
         }

        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|js|css)$
   {
         proxy_cache cache_one;
         proxy_cache_valid  200 10m;
         proxy_cache_valid  304 1m;
         proxy_cache_valid  301 302 1h;
         proxy_cache_valid  any 1m;
         proxy_cache_key $host$uri$is_args$args;
         proxy_set_header Host  $host;
         proxy_set_header X-Forwarded-For  $remote_addr;
         proxy_pass http://srv;
   }

[火星人 ] 關於NGINX虛擬目錄的訪問已經有705次圍觀

http://coctec.com/docs/service/show-post-2297.html