search

Home  >  Q&A  >  body text

nginx - nginix reverse proxy index configuration problem

The correct index is configured, but when accessing it, it gets 403. Is it because the default page will only go to the server to find files instead of accessing them through URL, because this page is dynamically generated by the server.

server {
      listen          80;
      server_name     manage.vs.com;
      root            /lee/web/;
      location / {
        index login.html;
      }
      location ~ \.(do|jsp|json|html)$ {
        proxy_pass        http://127.0.0.1:8080;
        proxy_set_header  X-Real-IP $remote_addr;
        proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header  Host $http_host;
      }
    }

Configuration is as above index login.html
This page can be opened if you directly enter http://manage.vs.com/login.html in the browser
But use the default http://manage. When vs.com is opened, a 403 error occurs because there is no login.html file in the specified root directory. This file is dynamically generated by the server.

阿神阿神2834 days ago462

reply all(1)I'll reply

  • 黄舟

    黄舟2017-05-16 17:09:21

    server {
        listen          80;
        server_name     manage.vs.com;
        root            /lee/web/;
        location / {
            index login.html;
        }
        location ~ \.(do|jsp|json|html)$ {
            proxy_pass        http://127.0.0.1:8080;
            proxy_set_header  X-Real-IP $remote_addr;
            proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header  Host $http_host;
        }
        location = / {
            proxy_pass        http://127.0.0.1:8080;
            proxy_set_header  X-Real-IP $remote_addr;
            proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header  Host $http_host;
        }
    }

    reply
    0
  • Cancelreply