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;
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
add a comment |
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
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
add a comment |
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
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
nginx
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
add a comment |
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
add a comment |
1 Answer
1
active
oldest
votes
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.
still getting"/usr/share/nginx/htmlhttp://requestb.in/1h6l0vn1"withlocation / 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_filesis only for adding physical files / virtual location blocks.
– Tero Kilkanen
Feb 2 '17 at 20:55
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
still getting"/usr/share/nginx/htmlhttp://requestb.in/1h6l0vn1"withlocation / 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_filesis only for adding physical files / virtual location blocks.
– Tero Kilkanen
Feb 2 '17 at 20:55
add a comment |
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.
still getting"/usr/share/nginx/htmlhttp://requestb.in/1h6l0vn1"withlocation / 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_filesis only for adding physical files / virtual location blocks.
– Tero Kilkanen
Feb 2 '17 at 20:55
add a comment |
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.
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.
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"withlocation / 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_filesis only for adding physical files / virtual location blocks.
– Tero Kilkanen
Feb 2 '17 at 20:55
add a comment |
still getting"/usr/share/nginx/htmlhttp://requestb.in/1h6l0vn1"withlocation / 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_filesis 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
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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