Nginx配置文件的反向代理

问题描述:项目需要预览pdf,前端控件支持的格式是http://192.168.0.1/pdf/a.pdf  是这样的,然后我就想给路径配个nginx反向代理就好了,但是配置的时候出问题了。

1、正确的配置

location / {
            root /var/www;
            index index.html index.htm;
        }

 location /pdf {
             alias /root/MSPAS/ ;
             index input.txt ;
         }

2、错误的配置

  因为我前面配置过一次vue的反向代理,然后我就在那个基础上复制修改的,然后怎么都不对。

location / {
            root /var/www;
            index index.html index.htm;
        }

 location /pdf {
             root /root/MSPAS/ ;
              index input.txt ;
         }

3、最后把root改成alias好了,这个问题应该是不能配多少root。

原文地址:https://www.cnblogs.com/zhangjd/p/11331968.html