• Home
    • English
    • 中文
  • About Us
  • Services
    • SEO Services
    • Website Design Service
  • Projects
  • Docs
  • Blog
    • Affiliate
    • Ecommerce
    • Frontend
    • linux
      • nginx
    • PHP
      • Magento
      • wordpress
    • Python
    • SEO
    • Web
  • Contact Us

Subscribe to Updates

Get the latest creative news from FooBar about art, design and business.

What's Hot

Design a plugin for wordpress woocommerce to display a tab to show attachment download

2024-04-06

TranslatePress v2.6.9 – WordPress Translation Plugin

2023-12-25

A Linux batch script converting pictures to webp format

2023-07-10
Facebook Twitter Instagram
  • 中文
  • English
Facebook Twitter Instagram Pinterest VKontakte
Weilai Tech Weilai Tech
  • Home
    • English
    • 中文
  • About Us
  • Services
    • SEO Services
    • Website Design Service
  • Projects
  • Docs
  • Blog
    • Affiliate
    • Ecommerce
    • Frontend
    • linux
      • nginx
    • PHP
      • Magento
      • wordpress
    • Python
    • SEO
    • Web
  • Contact Us
Weilai Tech Weilai Tech
Home»nginx»nginx image-proxy server conf
nginx

nginx image-proxy server conf

OxfordBy Oxford2020-07-25No Comments2 Mins Read
Facebook Twitter Pinterest LinkedIn Tumblr Email
Share
Facebook Twitter LinkedIn Pinterest Email

# Feel free to change this path of course (and keys_zone value as well, but also change the usage of it below).
proxy_cache_path /var/www/cache/resized levels=1:2 keys_zone=resizedimages:10m max_size=1G;

# Gzip was on in another conf file of mine…You may need to uncomment the next line.
#gzip on;
gzip_disable msie6;
gzip_static on;
gzip_comp_level 4;
gzip_proxied any;
# Again, be careful that you aren’t overwriting some other setting from another config’s http {} section.
gzip_types image/jpeg image/jpg image/png image/gif;

server {
# Replace with your sub/domain.
server_name image.yoursite.com;
root /var/www/cache/store/img;
index index.html;

resolver 8.8.8.8 8.8.4.4;

# This requests the original file from itself and then resizes the image.
location ~ ^/resize/(\d+)x(\d+)/(.*) {

# Again replace with your sub/domain.
proxy_pass http://image.yoursite.com/$3;

proxy_cache resizedimages;
proxy_cache_key “$host$document_uri”;
proxy_cache_valid 200 1d;
proxy_cache_valid any 1m;
proxy_cache_use_stale error timeout invalid_header updating;

image_filter resize $1 $2;
image_filter_jpeg_quality 90;
image_filter_buffer 20M;
image_filter_interlace on;
}

# Access denied.
location /resize {
return 403;
}

# RESIZED: http://image.yoursite.com/200×200/example.jpg
location ~ /(\d+x\d+/.*) {
try_files /$1 @img;
}

# ORIGINAL: http://image.yoursite.com/example.jpg
location / {
# If we don’t find the file locally download it.
error_page 404 = @proxy;
}

# This saves the resized image locally.
location @img {
set $remote_uri $uri;
set $protocol “http”;
if ($uri ~ “^/https?\:\/(.*)”) {
set $remote_uri $1;
}
if ($uri ~ “^/https.*”) {
set $protocol “https”;
}
set $full_uri “${protocol}://${remote_uri}”;

proxy_pass $full_uri;
proxy_store /var/www/cache/store/img/$full_uri;
}

# This gets the remote image and saves it locally.
location @proxy {

set $remote_uri $uri;
set $protocol “http”;
if ($uri ~ “^/https?\:\/(.*)”) {
set $remote_uri $1;
}
if ($uri ~ “^/https.*”) {
set $protocol “https”;
}
set $full_uri “${protocol}://${remote_uri}”;

# i thought with merge_slashes off this would work… =(
#if ($uri ~ “^/(.*)”) {
# set $full_uri $1;
#}
#set $full_uri $uri;

proxy_pass $full_uri;
proxy_connect_timeout 30s;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_store /var/www/cache/store/img$uri;
}

}

Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
Avatar photo
Oxford

Related Posts

secure wordpress with nginx config file

2021-06-08

how to setup W3 total cache on nginx server

2021-05-02

use simply static cache to instead fast-cgi cache to boost your wordpress 10x

2021-04-18

How to Configure nginx Reverse Proxy WordPress Cache for Apache

2021-04-15
Recent Posts
  • Design a plugin for wordpress woocommerce to display a tab to show attachment download
  • TranslatePress v2.6.9 – WordPress Translation Plugin
  • A Linux batch script converting pictures to webp format
  • Hearing aid listed company official website SEO case
  • how to use docker to run php5.6 plus apache
July 2020
M T W T F S S
 12345
6789101112
13141516171819
20212223242526
2728293031  
« Jun   Aug »
Tags
app branding design digital Docly docs etc faq fix github Helpdesk Image issue magento Manual marketing memecached Photography planing seo sequrity tips Travel ui/ux web WordPress 爬虫
Editors Picks
About Us

Guangzhou Weilai Technology is a foreign trade integrated marketing service provider focusing on Google as the drainage center and marketing self-built website as the carrier.

Email Us: [email protected]
Contact: +86 18676917505

Facebook Pinterest YouTube LinkedIn
Recent Posts
  • Design a plugin for wordpress woocommerce to display a tab to show attachment download
  • TranslatePress v2.6.9 – WordPress Translation Plugin
  • A Linux batch script converting pictures to webp format
  • Hearing aid listed company official website SEO case
  • how to use docker to run php5.6 plus apache
From Flickr
Website Design Case
© 2024 Copyright by Guangzhou Weilai Technology Co.,Ltd..
  • Home
  • About Us
  • SEO Services
  • Website Design Service
  • Projects
  • Blog
  • Contact Us

Type above and press Enter to search. Press Esc to cancel.