• Home
    • Cool Knowledge base
    • Light Knowledge base
    • Help Desk
    • OnePage Documentation
  • Services
    • Main Services
    • PPC Services
    • SEO Services
    • SMM Services
  • Docs
  • Blog
    • Affiliate
    • Ecommerce
    • Frontend
    • linux
      • nginx
    • PHP
      • Magento
      • wordpress
    • Python
    • SEO
    • Web
  • Forum
    • Forums
    • Forum Topics
    • Topic Details
    • Ask Question
  • Pages
  • Contact

Subscribe to Updates

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

What's Hot

VideoJS – multiple source demo

2022-03-08

Add custom field to Woocommerce tab

2022-03-07

Surror Product Tabs for WooCommerce

2022-03-07
Facebook Twitter Instagram
  • 中文
  • English
Facebook Twitter Instagram Pinterest VKontakte
SEO & Website build tips SEO & Website build tips
  • Home
    • Cool Knowledge base
    • Light Knowledge base
    • Help Desk
    • OnePage Documentation
  • Services
    • Main Services
    • PPC Services
    • SEO Services
    • SMM Services
  • Docs
  • Blog
    • Affiliate
    • Ecommerce
    • Frontend
    • linux
      • nginx
    • PHP
      • Magento
      • wordpress
    • Python
    • SEO
    • Web
  • Forum
    • Forums
    • Forum Topics
    • Topic Details
    • Ask Question
  • Pages
  • Contact
SEO & Website build tips SEO & Website build tips
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
  • VideoJS – multiple source demo
  • Add custom field to Woocommerce tab
  • Surror Product Tabs for WooCommerce
  • How To Scrape Amazon at Scale With Python Scrapy, And Never Get Banned
  • Compile a Jekyll project without installing Jekyll or Ruby by using Docker
July 2020
M T W T F S S
 12345
6789101112
13141516171819
20212223242526
2728293031  
« Jun   Aug »
Tags
app branding culture design digital Docly docs etc faq fashion featured fitness fix github Helpdesk Image issue leisure lifestyle magento Manual marketing memecached Photography picks planing seo sequrity tips Travel trending ui/ux web WordPress 爬虫
Editors Picks

Fujifilm’s 102-Megapixel Camera is the Size of a Typical DSLR

2021-01-05
Top Reviews
8.9

Which LED Lights for Nail Salon Safe? Comparison of Major Brands

By Oxford
8.9

Review: Xiaomi’s New Loudspeakers for Hi-fi and Home Cinema Systems

By Oxford
70

CES 2021 Highlights: 79 Top Photos, Products, and Much More

By Oxford
Advertisement
Demo
  • Facebook
  • Twitter
  • Instagram
  • Pinterest
About Us
About Us

Your source for the lifestyle news. This demo is crafted specifically to exhibit the use of the theme as a lifestyle site. Visit our main page for more demos.

We're accepting new partnerships right now.

Email Us: [email protected]
Contact: +1-320-0123-451

Facebook Twitter Instagram Pinterest YouTube LinkedIn
Recent Posts
  • VideoJS – multiple source demo
  • Add custom field to Woocommerce tab
  • Surror Product Tabs for WooCommerce
  • How To Scrape Amazon at Scale With Python Scrapy, And Never Get Banned
  • Compile a Jekyll project without installing Jekyll or Ruby by using Docker
From Flickr
Ascend
terns
casual
riders on the storm
chairman
mood
monument
liquid cancer
blue
basement
ditch
stars
© 2025 Designed by 九号资源网.

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