Nginx防盗链

利用Nginx进行来源地址拦截,只要来源地址符合原资源地址,则可以访问,否则返回403状态码或者非法图标

1、目录展示

  Nginx防盗链_第1张图片

2、A项目下jsp页面

<%--
  Created by IntelliJ IDEA.
  User: zheng
  Date: 2020/2/10
  Time: 18:08
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Nginx防盗链title>
head>
<body>
    <img src="http://www.a.com:8080/A/img/1.png">
body>
html>

3、B项目下jsp页面

<%--
  Created by IntelliJ IDEA.
  User: zheng
  Date: 2020/2/10
  Time: 15:01
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Nginx解决跨域问题title>
head>
<body>
    数据:<input type="text" name="username" id="username"/>
    <input type="button" id="button" value="请求"/>


    <hr/>

    <img src="http://www.znzn.com/A/img/1.png">
body>
html>

4、修改nginx.conf文件、重启Nginx

  Nginx防盗链_第2张图片

5、A项目访问效果

  Nginx防盗链_第3张图片

6、效果展示

  Nginx防盗链_第4张图片

 

   Nginx防盗链_第5张图片

 

你可能感兴趣的:(Nginx防盗链)