一、nginx搭建好后无法访问后端Tomcat项目

         通过项目名称过滤的方式访问Tomcat,比如项目名称叫easy。

              修改其server下的location目录,配置如下:

                 

 1 server
 2   {
 3    #监听的端口
 4    listen *:80 default;
 5    
 6    #访问的服务器(localhost可以使用你自己的IP地址)
 7    server_name  localhost;
 8 
 9     #前端代码存放目录
10      root  /usr/local/nginx/html;
11      index index.html index.htm;
12 
13      #过滤条件就是项目名称
14      location /easylab/ {
15        proxy_set_header Host  $host;
16            proxy_set_header X-Forwarded-For  $remote_addr;         
17        proxy_pass http://localhost:8080;
18     }
19 
20    #过滤文件域名结尾是如下类型的,可以进行时间设置加载
21     location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|js|css)$
22     {
23       expires      30d;
24     }
25    
26    }
27     
View Code

相关文章:

  • 2021-04-14
  • 2022-02-07
  • 2021-09-02
  • 2021-08-16
  • 2021-04-24
  • 2022-12-23
  • 2022-12-23
  • 2021-11-04
猜你喜欢
  • 2021-10-08
  • 2021-07-17
  • 2021-05-15
  • 2021-08-24
  • 2021-05-27
  • 2021-09-24
  • 2021-12-07
相关资源
相似解决方案