nginx: try_files and external URLHow to make nginx reverse proxy let 503 error pages pass through to client?Blank Page: wordpress on nginx+php-fpmnginx redirect issue with upstream configurationnginx rewrite throw 404 with last and breakNginx regex to get uri minus locationCodeIgniter nginx rewrite rules for i8ln URL'sConfigure NGINX : How to handle 500 Error on upstream itself, While Nginx handle other 5xx errorsWhy Nginx calls for invalid certificate in non-existent subdomains just to redirect to 404?Nginx reverse proxy to many local servers + webserver duty

Gerrymandering Puzzle - Rig the Election

How to detect nM levels of Copper(I) Oxide in blood?

Subnumcases as a part of align

Copper as an adjective to refer to something made of copper

Efficient deletion of specific list entries

Convert Numbers To Emoji Math

Endgame puzzle: How to avoid stalemate and win?

Given a safe domain, are subdirectories safe as well?

All of my Firefox add-ons been disabled suddenly, how can I re-enable them?

GitLab account hacked and repo wiped

Why would a military not separate its forces into different branches?

Why can't argument be forwarded inside lambda without mutable?

How did the Apollo guidance computer handle parity bit errors?

What is more safe for browsing the web: PC or smartphone?

In "Avengers: Endgame", what does this name refer to?

Can an Iranian citizen enter the USA on a Dutch passport?

Two denim hijabs

Where did Lovecraft write about Carcosa?

Can a player choose to add detail and flavor to their character's spells and abilities?

How to preserve a rare version of a book?

What is monoid homomorphism exactly?

Which "exotic salt" can lower water's freezing point by –70 °C?

How to say something covers all the view up to the horizon line?

How long does it take a postcard to get from USA to Germany?



nginx: try_files and external URL


How to make nginx reverse proxy let 503 error pages pass through to client?Blank Page: wordpress on nginx+php-fpmnginx redirect issue with upstream configurationnginx rewrite throw 404 with last and breakNginx regex to get uri minus locationCodeIgniter nginx rewrite rules for i8ln URL'sConfigure NGINX : How to handle 500 Error on upstream itself, While Nginx handle other 5xx errorsWhy Nginx calls for invalid certificate in non-existent subdomains just to redirect to 404?Nginx reverse proxy to many local servers + webserver duty






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








1















I'd like to create a dynamic thumbnail generator and pass all requests through nginx and test weather the files exist using try_files.



The fallback should be an external URL, how can I achieve this?



 server 
listen 80;
server_name static.stage.domain.example;

location /
alias /home/fh/static/$1;
try_files $uri $uri/ @bla;


location @bla
proxy_set_header Host http://www.myurl.example?resize=$uri;





Solution
This is what I've been looking for: (working example):



server 
listen 80;

server_name static.example.com;

location /
root /home/example/static/uploads/thumbnail;
try_files $uri @redirect;


location @redirect
expires 30s;
return 301 https:/example.com/thumbnail$request_uri;











share|improve this question
























  • The documentation says it takes a URI. Have you considered just putting a URI in there? What happens when you try what you did above? nginx.org/en/docs/http/ngx_http_core_module.html#try_files

    – Tim
    Feb 2 '17 at 19:59











  • location / alias /home/fh/nginxtest/$1; try_files $uri $uri/ http://google.com; results in "/usr/share/nginx/htmlhttp://google.com" failed (2: No such file or directory)

    – user398486
    Feb 2 '17 at 20:28


















1















I'd like to create a dynamic thumbnail generator and pass all requests through nginx and test weather the files exist using try_files.



The fallback should be an external URL, how can I achieve this?



 server 
listen 80;
server_name static.stage.domain.example;

location /
alias /home/fh/static/$1;
try_files $uri $uri/ @bla;


location @bla
proxy_set_header Host http://www.myurl.example?resize=$uri;





Solution
This is what I've been looking for: (working example):



server 
listen 80;

server_name static.example.com;

location /
root /home/example/static/uploads/thumbnail;
try_files $uri @redirect;


location @redirect
expires 30s;
return 301 https:/example.com/thumbnail$request_uri;











share|improve this question
























  • The documentation says it takes a URI. Have you considered just putting a URI in there? What happens when you try what you did above? nginx.org/en/docs/http/ngx_http_core_module.html#try_files

    – Tim
    Feb 2 '17 at 19:59











  • location / alias /home/fh/nginxtest/$1; try_files $uri $uri/ http://google.com; results in "/usr/share/nginx/htmlhttp://google.com" failed (2: No such file or directory)

    – user398486
    Feb 2 '17 at 20:28














1












1








1


1






I'd like to create a dynamic thumbnail generator and pass all requests through nginx and test weather the files exist using try_files.



The fallback should be an external URL, how can I achieve this?



 server 
listen 80;
server_name static.stage.domain.example;

location /
alias /home/fh/static/$1;
try_files $uri $uri/ @bla;


location @bla
proxy_set_header Host http://www.myurl.example?resize=$uri;





Solution
This is what I've been looking for: (working example):



server 
listen 80;

server_name static.example.com;

location /
root /home/example/static/uploads/thumbnail;
try_files $uri @redirect;


location @redirect
expires 30s;
return 301 https:/example.com/thumbnail$request_uri;











share|improve this question
















I'd like to create a dynamic thumbnail generator and pass all requests through nginx and test weather the files exist using try_files.



The fallback should be an external URL, how can I achieve this?



 server 
listen 80;
server_name static.stage.domain.example;

location /
alias /home/fh/static/$1;
try_files $uri $uri/ @bla;


location @bla
proxy_set_header Host http://www.myurl.example?resize=$uri;





Solution
This is what I've been looking for: (working example):



server 
listen 80;

server_name static.example.com;

location /
root /home/example/static/uploads/thumbnail;
try_files $uri @redirect;


location @redirect
expires 30s;
return 301 https:/example.com/thumbnail$request_uri;








nginx






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Feb 6 '17 at 8:38







user398486

















asked Feb 2 '17 at 19:38









user398486user398486

63




63












  • The documentation says it takes a URI. Have you considered just putting a URI in there? What happens when you try what you did above? nginx.org/en/docs/http/ngx_http_core_module.html#try_files

    – Tim
    Feb 2 '17 at 19:59











  • location / alias /home/fh/nginxtest/$1; try_files $uri $uri/ http://google.com; results in "/usr/share/nginx/htmlhttp://google.com" failed (2: No such file or directory)

    – user398486
    Feb 2 '17 at 20:28


















  • The documentation says it takes a URI. Have you considered just putting a URI in there? What happens when you try what you did above? nginx.org/en/docs/http/ngx_http_core_module.html#try_files

    – Tim
    Feb 2 '17 at 19:59











  • location / alias /home/fh/nginxtest/$1; try_files $uri $uri/ http://google.com; results in "/usr/share/nginx/htmlhttp://google.com" failed (2: No such file or directory)

    – user398486
    Feb 2 '17 at 20:28

















The documentation says it takes a URI. Have you considered just putting a URI in there? What happens when you try what you did above? nginx.org/en/docs/http/ngx_http_core_module.html#try_files

– Tim
Feb 2 '17 at 19:59





The documentation says it takes a URI. Have you considered just putting a URI in there? What happens when you try what you did above? nginx.org/en/docs/http/ngx_http_core_module.html#try_files

– Tim
Feb 2 '17 at 19:59













location / alias /home/fh/nginxtest/$1; try_files $uri $uri/ http://google.com; results in "/usr/share/nginx/htmlhttp://google.com" failed (2: No such file or directory)

– user398486
Feb 2 '17 at 20:28






location / alias /home/fh/nginxtest/$1; try_files $uri $uri/ http://google.com; results in "/usr/share/nginx/htmlhttp://google.com" failed (2: No such file or directory)

– user398486
Feb 2 '17 at 20:28











1 Answer
1






active

oldest

votes


















0














URI is the resource part of a full URL, that is, a resource on the current server. You cannot refer to an external resource in try_files directive.



You need to add proxy_pass http://example.com; in your location @bla configuration section to pass the request to an external service.






share|improve this answer

























  • still getting "/usr/share/nginx/htmlhttp://requestb.in/1h6l0vn1" with location / alias /home/fh/nginxtest/$1; try_files $uri proxy_pass http://requestb.in/1h6l0vn1;

    – user398486
    Feb 2 '17 at 20:52












  • I made my answer more clear. try_files is only for adding physical files / virtual location blocks.

    – Tero Kilkanen
    Feb 2 '17 at 20:55











Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "2"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f830234%2fnginx-try-files-and-external-url%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














URI is the resource part of a full URL, that is, a resource on the current server. You cannot refer to an external resource in try_files directive.



You need to add proxy_pass http://example.com; in your location @bla configuration section to pass the request to an external service.






share|improve this answer

























  • still getting "/usr/share/nginx/htmlhttp://requestb.in/1h6l0vn1" with location / alias /home/fh/nginxtest/$1; try_files $uri proxy_pass http://requestb.in/1h6l0vn1;

    – user398486
    Feb 2 '17 at 20:52












  • I made my answer more clear. try_files is only for adding physical files / virtual location blocks.

    – Tero Kilkanen
    Feb 2 '17 at 20:55















0














URI is the resource part of a full URL, that is, a resource on the current server. You cannot refer to an external resource in try_files directive.



You need to add proxy_pass http://example.com; in your location @bla configuration section to pass the request to an external service.






share|improve this answer

























  • still getting "/usr/share/nginx/htmlhttp://requestb.in/1h6l0vn1" with location / alias /home/fh/nginxtest/$1; try_files $uri proxy_pass http://requestb.in/1h6l0vn1;

    – user398486
    Feb 2 '17 at 20:52












  • I made my answer more clear. try_files is only for adding physical files / virtual location blocks.

    – Tero Kilkanen
    Feb 2 '17 at 20:55













0












0








0







URI is the resource part of a full URL, that is, a resource on the current server. You cannot refer to an external resource in try_files directive.



You need to add proxy_pass http://example.com; in your location @bla configuration section to pass the request to an external service.






share|improve this answer















URI is the resource part of a full URL, that is, a resource on the current server. You cannot refer to an external resource in try_files directive.



You need to add proxy_pass http://example.com; in your location @bla configuration section to pass the request to an external service.







share|improve this answer














share|improve this answer



share|improve this answer








edited Feb 2 '17 at 20:55

























answered Feb 2 '17 at 20:42









Tero KilkanenTero Kilkanen

20.7k22744




20.7k22744












  • still getting "/usr/share/nginx/htmlhttp://requestb.in/1h6l0vn1" with location / alias /home/fh/nginxtest/$1; try_files $uri proxy_pass http://requestb.in/1h6l0vn1;

    – user398486
    Feb 2 '17 at 20:52












  • I made my answer more clear. try_files is only for adding physical files / virtual location blocks.

    – Tero Kilkanen
    Feb 2 '17 at 20:55

















  • still getting "/usr/share/nginx/htmlhttp://requestb.in/1h6l0vn1" with location / alias /home/fh/nginxtest/$1; try_files $uri proxy_pass http://requestb.in/1h6l0vn1;

    – user398486
    Feb 2 '17 at 20:52












  • I made my answer more clear. try_files is only for adding physical files / virtual location blocks.

    – Tero Kilkanen
    Feb 2 '17 at 20:55
















still getting "/usr/share/nginx/htmlhttp://requestb.in/1h6l0vn1" with location / alias /home/fh/nginxtest/$1; try_files $uri proxy_pass http://requestb.in/1h6l0vn1;

– user398486
Feb 2 '17 at 20:52






still getting "/usr/share/nginx/htmlhttp://requestb.in/1h6l0vn1" with location / alias /home/fh/nginxtest/$1; try_files $uri proxy_pass http://requestb.in/1h6l0vn1;

– user398486
Feb 2 '17 at 20:52














I made my answer more clear. try_files is only for adding physical files / virtual location blocks.

– Tero Kilkanen
Feb 2 '17 at 20:55





I made my answer more clear. try_files is only for adding physical files / virtual location blocks.

– Tero Kilkanen
Feb 2 '17 at 20:55

















draft saved

draft discarded
















































Thanks for contributing an answer to Server Fault!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f830234%2fnginx-try-files-and-external-url%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

How to write a 12-bar blues melodyI-IV-V blues progressionHow to play the bridges in a standard blues progressionHow does Gdim7 fit in C# minor?question on a certain chord progressionMusicology of Melody12 bar blues, spread rhythm: alternative to 6th chord to avoid finger stretchChord progressions/ Root key/ MelodiesHow to put chords (POP-EDM) under a given lead vocal melody (starting from a good knowledge in music theory)Are there “rules” for improvising with the minor pentatonic scale over 12-bar shuffle?Confusion about blues scale and chords

What if the end-user didn't have the required library?What is setup.py?What is a clean, pythonic way to have multiple constructors in Python?What does Ruby have that Python doesn't, and vice versa?What is the reason for having '//' in Python?How do I create a namespace package in Python?How to package shared objects that python modules depend on?setuptools vs. distutils: why is distutils still a thing?Navigation in Windows 10 vs code not going to virtualenv library when the same library is installed at user levelPython create package for local usePackaging a project that uses multiple python versionsWhy is permission denied on pip install except for when “--user” is included at end of command?

Esgonzo ibérico Índice Descrición Distribución Hábitat Ameazas Notas Véxase tamén "Acerca dos nomes dos anfibios e réptiles galegos""Chalcides bedriagai"Chalcides bedriagai en Carrascal, L. M. Salvador, A. (Eds). Enciclopedia virtual de los vertebrados españoles. Museo Nacional de Ciencias Naturales, Madrid. España.Fotos