从http切换至https
许多差别ip的图片地址需要统一举行署理
部分图片地址是重定向地址
nginx设置
主站地址:https://192.168.123.100/
- server {
- listen 443 ssl;
- server_name localhost;
-
- #ssl证书
- ssl_certificate ../ssl/ca.crt;
- #私钥文件
- ssl_certificate_key ../ssl/ca.key;
- ssl_session_cache shared:SSL:1m;
- ssl_session_timeout 5m;
- ssl_ciphers HIGH:!aNULL:!MD5;
- ssl_prefer_server_ciphers on;
-
- #charset koi8-r;
- #access_log logs/host.access.log main;
- location / {
- root html;
- index index.html index.htm;
- }
- location /proxyAgent {
- proxy_set_header Host $host;
- proxy_set_header X-Real-IP $remote_addr;
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
- proxy_set_header X-Forwarded-Proto $scheme;
- proxy_intercept_errors on;
- if ($args ~* "imgUrl=(.*)") {
- proxy_pass $1;
- error_page 301 302 = @handle_redirect;
- }
- }
- location @handle_redirect {
- set $saved_redirect_location $upstream_http_location;
- rewrite ^(.*)$ $saved_redirect_location break;
- proxy_set_header Host $host;
- proxy_set_header X-Real-IP $remote_addr;
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
- proxy_set_header X-Forwarded-Proto $scheme;
- proxy_pass $saved_redirect_location;
- }
- }
复制代码
- <img src="/proxyAgent/?imgUrl=http://192.168.123.102:8093/test/123456?url=1234567&type=picpic">
- <img src="/proxyAgent/?imgUrl=http://192.168.123.102/test/1.jpg">
- <img src="/proxyAgent/?imgUrl=https://192.168.123.105/3.jpg">
复制代码
- 192.168.123.102:8093为java模拟重定向
- @GetMapping("/{picId}")
- public void getPic(@PathVariable("picId") String picId,
- @RequestParam("url") String url,
- @RequestParam(value = "type") String type, HttpServletResponse response) throws IOException {
- if (StrUtil.isBlank(type)) {
- return;
- }
- if (StrUtil.isBlank(url)) {
- return;
- }
- System.out.println(type);
- System.out.println(url);
- response.sendRedirect("http://192.168.123.102/test/2.jpg");
- }
复制代码 终极三张图片均可正常访问
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。 |