Quantcast
Channel: Nginx Forum - Nginx Mailing List - English
Viewing all 7229 articles
Browse latest View live

proxy_cache and X-Accel-Redirect (3 replies)

$
0
0
Hi,
I currently get requests that are resolved with an external server to a file with X-Accel-Redirect:

for example:

/data/asd-asd-asd -> proxied to a backend -> resolves to file.xls
/data/qqq-qqq-qqq -> proxied to a backend -> resolves to file.xls
/data/123-123-123 -> proxied to a backend -> resolves to image.jpeg

I want to cache the resulting files with nginx, as the initial access is very costly (they are accessed over the network). On first access they should be copied to a local cache, following requests should also go to the backend but actually serve the file from cache.

My current config: https://zerobin.davidventura.com.ar/?0018df75a5d31f2c#Un5Eo10lo4eRnhY7ngQiHlSTErCVH/8zjRN+qS0JSl0=


Note: The files are quite large (up to 4gb)

I added the proxy_cache directives to both the requests path and the internal path but none of them are working.

/cache/ is never populated, and the X-*-Cache headers are not present in the response

rewrite in custom 404 location (no replies)

$
0
0
is it possible to create "if" rule with rewrite action inside custom 404
location?
the task is fallback to jpg if upstream returns 404 for .webp request.
i've double-checked regexp's - they seems to be write....



location ~* \.(jpg|mp4|svg|jpeg|gif|png|css|bmp|js|swf|webp|jp2|ico)$ {

etag on;

proxy_cache site;

proxy_cache_valid 404 302 1m;

expires max;

proxy_cache_valid 2h;

proxy_pass http://cdn;

proxy_intercept_errors on;

proxy_connect_timeout 5s;

proxy_next_upstream error timeout http_404 http_403 http_500
http_502 http_503 http_504;

error_page 404 /webp.html;

}


location = /webp.html {

if ($request_filename ~* ^.+.webp$) {

rewrite ^/(.*)\.webp$ /$1.jpg redirect;

}

root /var/www/;

}
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx

Nginx 404 while accessing app (4 replies)

$
0
0
I have one AngularJS application deployed on port 8080. It can be access as http://ip:8080. Now I have deployed the application on nginx and I am trying to access this application via nginx reverse proxy configuration but I am getting 404 error in nginx log as it looks like the nginx is searching the application in wrong directory. My application is in /usr/share/nginx/html directory but the reverse proxy is looking the app in /etc/nginx/html. Here is my configuration and I am using Ubuntu 16.04

server {
listen 80 default_server;
server_name _;
location /app/ {
proxy_redirect off;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://localhost:8080/;
}
}

server {
listen 8080;
root /usr/share/nginx/html;
index index.html index.htm;
server_name _;
location / {
try_files $uri $uri/ /index.html;

}
error_page 404 /404.html;
error_page 403 /403.html;
error_page 405 =200 $uri;
}

Can somebody tell me what am I doing wrong?

nginx-1.13.2 (no replies)

$
0
0
Changes with nginx 1.13.2 27 Jun 2017

*) Change: nginx now returns 200 instead of 416 when a range starting
with 0 is requested from an empty file.

*) Feature: the "add_trailer" directive.
Thanks to Piotr Sikora.

*) Bugfix: nginx could not be built on Cygwin and NetBSD; the bug had
appeared in 1.13.0.

*) Bugfix: nginx could not be built under MSYS2 / MinGW 64-bit.
Thanks to Orgad Shaneh.

*) Bugfix: a segmentation fault might occur in a worker process when
using SSI with many includes and proxy_pass with variables.

*) Bugfix: in the ngx_http_v2_module.
Thanks to Piotr Sikora.


--
Maxim Dounin
http://nginx.org/
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx

build error for 1.13.2 (2 replies)

$
0
0
Hello!

On Cygwin 64-bit, I am getting this build error (worked fine on Cygwin
32-bit) :

-o objs/src/os/unix/ngx_udp_send.o \
src/os/unix/ngx_udp_send.c
cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g
-D FD_
SETSIZE=2048 -I src/core -I src/event -I src/event/modules -I src/os/unix
-I /us
r/include/libxml2 -I objs \
-o objs/src/os/unix/ngx_udp_sendmsg_chain.o \
src/os/unix/ngx_udp_sendmsg_chain.c
src/os/unix/ngx_udp_sendmsg_chain.c: In function `ngx_sendmsg':
src/os/unix/ngx_udp_sendmsg_chain.c:274:16: error: `struct in_pktinfo' has
no me
mber named `ipi_spec_dst'
pkt->ipi_spec_dst = sin->sin_addr;
^
objs/Makefile:847: recipe for target
'objs/src/os/unix/ngx_udp_sendmsg_chain.o'
failed
make[1]: *** [objs/src/os/unix/ngx_udp_sendmsg_chain.o] Error 1
make[1]: Leaving directory '/home/kevin.worthington/nginx-1.13.1'
Makefile:8: recipe for target 'build' failed
make: *** [build] Error 2

Help and/or patches are much appreciated. Thank you!

Best regards,
Kevin
--
Kevin Worthington
kworthington (at} gmail {dot) com
https://kevinworthington.com/
https://twitter.com/kworthington
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx

Proxy_cache_key based on custom header (no replies)

$
0
0
Hi.

I'm trying to use 2 level proxying to cache files delivered with X-Accel-Redirect. This kinda works, the only thing missing is getting the cache_key to be the filename.


If `proxy_cache` is unset (or set to the default), the caching mechanism "works":
- Every request gets cached (good)
- Different URLs that map to the same file get mapped to different cache keys (bad)
- I get the header "X-Banana" with the correct file path (good)

If `proxy_cache` is set to `$sent_http_x_test_header`:
- Every request gets cached (good)
- All URLs map to the same cache (very bad!)
- I don't get the 'X-Banana' header at all

This leads me to believe that in the second case, `$sent_http_x_test_header` is empty. But it's not in the first case? Why? What can I do?

Full config below:


proxy_cache_path /cache/nginx levels=1:2 keys_zone=cache:10m inactive=24h;

upstream backend {
server unix:///tmp/streaming-backend.sock;
}

server {
listen 443 ssl;
listen [::]:443 ssl;
include /etc/nginx/ssl;
index index.html;
server_name pilotage.streamall.pw;
gzip off;

proxy_cache_min_uses 1;
proxy_cache cache;
proxy_cache_valid 200 24h;

location /v/ {
rewrite /v/(.+) /$1 break;
proxy_pass http://127.0.0.1:9999/;

proxy_request_buffering off; # needs 1.7.11
proxy_ignore_headers X-Accel-Expires Expires Cache-Control Set-Cookie;

# proxy_cache_key $sent_http_x_test_header;
add_header X-Proxy-Cache $upstream_cache_status;
add_header X-Banana $sent_http_x_test_header;

}

}

server {
listen 9999;
location / {
uwsgi_pass backend;
include uwsgi_params;

proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

location /converted/ {
internal;
root /nfs/;
add_header X-Test-Header $document_uri;
}
}

Strange issue after nginx update (no replies)

$
0
0
Hi,
could you please help me solve this issue? I'm getting crazy!

Before the nginx update my client worked perfectly: it posted files to my website without any delay.

How, after nginx update (ubuntu 16.04 LTS) I've got this issue:

- the client posts files successfully but the answer of the post is delayed. The more the file is bigger, the more the answer is delayed.

I put a sniffer into the website' server and I noticed that the nginx receives the post but it waits to transfer the file to php-fpm process, so also the answer to the client is delayed

The nginx server is:

nginx/1.10.0 (Ubuntu) and its conf is:

-----
user www-data;
worker_processes auto;
pid /run/nginx.pid;

events {
worker_connections 768;
# multi_accept on;
}

http {
sendfile on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
client_max_body_size 0;
log_not_found off;
server_name_in_redirect off;
client_body_timeout 120s;
autoindex off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log info;
gzip on;
gzip_disable "msie6";
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
---

and website's php-fpm conf is:

server {
listen 80;
server_name test.it;
server_name_in_redirect off;
autoindex off;
client_max_body_size 500m;
index index.html;
root /home/test/test;
location ~ \.(php|html|htm|php3)$ {
try_files $uri 404;
fastcgi_pass unix:/run/php/mdtest-fpm.sock;
include fastcgi_params;
}
}

fastcgi_params config:

fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;

fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param REQUEST_SCHEME $scheme;
fastcgi_param HTTPS $https if_not_empty;

fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;

fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
#fastcgi_param SERVER_NAME $server_name;
fastcgi_param SERVER_NAME $http_host;

# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS 200;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;


Thanks a lot,
Andrea






ANDREA SORACCHI
+39 329 0512704
System Engineer

+39 0521 24 77 91
soracchi@netbuilder.it
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx

Measuring nginx's efficiency (3 replies)

$
0
0
Hello,

with your help I managed to configure nginx and our website now can be
accessed both - through apache and nginx.

Now, how can I prove to my boss that nginx is more efficient than apache
to switch to it? How do I measure its performance and compare it to that
of apache? Which tools would you recommend?

Thank you in advance!

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx

Nginx redirect quey string to url (2 replies)

$
0
0
I am trying to redirect a query string to url and I am using like this but it is somehow not working. Can somebody help?

rewrite ^/abc/xyz/def.php?Id=13 http://www.example.com/fhu/foo permanent;
rewrite ^/abc/xyz/def.php?Id=14 http://www.example.com/fhu/bar permanent;

XSLT Error - parser error : Document is empty (no replies)

$
0
0
I have been using the same XSLT files and proxy to an xml document for several generations without any problem. Recently (~1.11) I am getting an error when I do 'nginx -t':

/etc/nginx/xsl/so.xslt:1: parser error : Document is empty
error
xsltParseStylesheetFile : cannot parse /etc/nginx/xsl/so.xslt
nginx: [error] xsltParseStylesheetFile("/etc/nginx/xsl/so.xslt") failed in /etc/nginx/sites-enabled/miconcinemas.com:220
nginx: configuration file /etc/nginx/nginx.conf test failed

I have made no changes to the config or the xslt but have never seen this error before.

When I use xlstproc using the same stylesheet with the url to the xml file, the transform works as expected. I am uncertain why this behavior changed.

I am looking for suggestions on how I might diagnose this issue further.

rewrite with regex to use proxy_pass (no replies)

$
0
0
Hello,

I have a question, I wish I could parser a url and retrieve fields to
inject them to another server.

However, I can not. Here is my test:

URL :
http://mywebsite.net/folder1/folder2/hit.php?s=11111&s2=&p=home::index&x2=[box]&apvr=[5.0]&idclient=&na=&ref=

location ~ ^/folder1/folder2/ {

rewrite
^/folder1/folder2/hit.php?s=11111&s2=&p=(.*)::(.*)&x2=[box]&apvr=[5.0]&idclient=&na=&ref= /index.php?arg1=$1&arg2=$2
break;

proxy_pass http://myinternalsrv.localdom;
}

In my test, I want to retrieve the pattern "home" and "index" but it
does not work. Would you have an idea?

Thank you very much for your information.

Alex.
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx

ngx_http_sub_module causes requests to hang on a simple match. (no replies)

$
0
0
I've built with the sub filter enabled and I'm finding it hangs requests if there is a match. It is a very simple substitution/replace. I've resorted to following the request in GDB and the sub module completes and calls the next body filter (which in my case appears to be the charset module). I have no other odd modules enabled other than using threads with a thread pool size of two (shouldn't matter, right?). Pausing all the threads in GDB shows no obvious place it is hanging.

If I change the match string to something that doesn't match anything, the request works fine.

Here is my config:

location / {
root html;
index index.html index.htm;
sub_filter '</title>' 'xxx</title>';
sub_filter_once on;
}

nginx -V
nginx version: nginx/1.7.11
built by gcc 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.4)
configure arguments: --with-http_sub_module --with-debug --with-threads --with-cc-opt='-O0 -g'

Thanks!

Client timed out errors !! (no replies)

$
0
0
Hi,

We're seeing following info logs during serving mp4 videos via nginx :

2017/07/03 15:42:10 [info] 14725#100906: *964419 client timed out (60:
Operation timed out) while sending mp4 to client,

Is there anything we can do to fix it ?

Thanks in advance !!

Shahzaib
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx

Custom error_log format (no replies)

$
0
0
Hello,
I would like to have / to add the $request_id variable in the error_log, but I read that the only possible way is to add it to the source code. Has anyone here an experience with that, which file and what should I add? Or some other workaround?
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx

Does Nginx supports If-Range ? (no replies)

$
0
0
Hello everyone!

I don't know if it is an expected behaviour or a bug:


Scenario 1(OK): If I perform a request *with the header Range*, Nginx
serves the *partial content(HTTP 206)*.

Scenario 2 (NOT OK): If I perform a request *with the header Range AND the
header "If-Range" *with the Etag, Nginx serves the *entire file*(200). Why
not serve the partial content if its cached version matches the If-Range
header?

In both scenarios the file is already cached.

Here is my conf: https://pastebin.com/gQQ0GSg6

Here are my requests and my files: https://pastebin.com/rxLwYaSK


The error happened on my server(Nginx 1.10.2) but I was also able to
reproduce it on my Macbook (nginx 1.12.0).

Thanks for any help :)

Kinds,
NM
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx

prxy_buffering (no replies)

$
0
0
I am trying to check the functionality of proxy_buffering . can you please provide me with some sample test scenario.
Basically I want to visualise the behaviours of nginx when proxy_buffering is on and off .
And also please share what are the parameter gets effected when proxy_buffering is on or off .

Nginx Tuning (no replies)

$
0
0
Hi,

I am trying to tune nginx server.
I want to restrict number of client connection per server and restrict bandwidth.
I tried
worker_connections 2;
for max connections in nginx.conf file.
but its connecting only after worker_connection value set to 7.

my conf file look like below.

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

# Load dynamic modules. See /usr/share/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;

events {
worker_connections 7;
}

thanks.

Is there a module that can prettify the page output before it is send to the requesting client? (no replies)

$
0
0
Is there a module that can prettify the HTML before it gets sent to the
client? Some think like that must be run before the zip stage.

--
Frank Church

=======================
http://devblog.brahmancreations.com
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx

map configuration (1 reply)

$
0
0
Hello:

Need help understanding this piece of Nginx configuration:


===
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
===


What does the last line mean?

TIA,



--
-Dan Edwards-
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx

proxy_set_header directives don't inherit from father context (1 reply)

$
0
0
i found if i didn't configure any proxy_set_header directives in a context, it will inherit those directives from father context automatic, but if i set one in current context, the inheritance won't work.
my configration is like bellow:

http {
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $host;
server {
listen 80;
server_name example.com;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
location / {
proxy_pass http://huiju_nginx_ppr1;
}
}

i expected the X-Forwarded-For and X-Forwarded-Proto header will be set, but it didn't.
what happend?
Viewing all 7229 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>