Quantcast
Channel: Nginx Forum
Viewing all 53287 articles
Browse latest View live

proxy_pass and trailing / decode uri

$
0
0
Hi,

Sorry if it was already asked but I'd like to know if the only way to
prevent Nginx from decoding uri while using proxy_pass is:
https://stackoverflow.com/a/37584656/3515745

Here is my (simplified) conf:

server {
server_name domain1.com;

location / {
proxy_pass http://127.0.0.1:81;

}

location /api {
proxy_pass http://127.0.0.1:82/;

}
}

Location "/" is perfectly working. My problem is that "/api" location will
decode special character.
To illustrate my problem:

http://domain1.com/image1.png
=> HTTP 200
http://domain1.com/*api*/resource1.png
=> HTTP 200

http://domain1.com/image1+2.png
=> HTTP 200
http://domain1.com/*api*/resource1+2.png
=> HTTP 404

http://domain1.com/image1 2.png
=> HTTP 200
http://domain1.com/*api*/resource1 2.png
=> HTTP 404

I would like to know how to make my "/api" location respond like "/"
without decoding %?
This solution https://stackoverflow.com/a/37584656/3515745 seems to be
just a workaround.

Thanks for any hints !

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

Re: location blocks, and if conditions in server context

$
0
0
On Thu, Mar 08, 2018 at 08:57:29AM +0000, Lucas Rolff wrote:

Hi there,

> I indeed thought about having a separate server {} block in case there’s the http to https redirect for a specific domain.
> Since it depends on the domain, I can’t make a general one to match everything.

So, if I read this correctly, the new "requirement statement" is: some
domains want to redirect everything (apart from the letsencrypt piece)
from http to https; and some domains do not want to redirect anything
from http to https.

In that case, the one server with "listen 80 default;" and the two
locations, one with "return 301" and the other with "proxy_pass"; plus
the multiple servers with "listen 443" should Just Work.

If you do want the to-https redirect for this domain, do not add "listen
80" in the 443 server. If you do not want the to-https redirect for that
domain, do add "listen 80" in the 443 server.

Am I missing something?

> > Or: you use $sslproxy_protocol. Where does that come from?
>
> $sslproxy_protocol is a simple map doing:
>
> map $https $sslproxy _protocol {
> default "http";
> SSL "https";
> on "https";
> }

Because I don't know what else you use that variable for, perhaps you
could make a new variable $redirect_to_https, like so (untested):

map $https$uri $redirect_to_https {
default "yes";
~^SSL "no";
~^on "no";
~^/.well-known/ "no";
}

and then redirect based on the value of that variable, where it might matter.

(I presume that $https is empty in http-mode, per http://nginx.org/r/$https)

I prefer the first solution, without the extra variable-and-if; but it's
not my server.

Good luck with it,

f
--
Francis Daly francis@daoine.org
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx

Re: nginx + php-fpm: REQUEST_URI disappears for files that end with .php

$
0
0
On Thu, Mar 08, 2018 at 01:48:41PM +0200, ST wrote:

Hi there,

* What request do you make? (e.g. /rus_example.php)
* Does the matching file exist on the filesystem
(e.g. /usr/local/nginx/html/rus_example.php)?
* If yes - what response do you want, and what response do you get?
* If no - what response do you want, and what response do you get?

> error_page 404 = /netcat/require/e404.php;
>
> location ~ \.php$ {
> if ($args ~ "netcat_files/") {
> expires 7d;
> add_header Cache-Control "public";
> }
>
> fastcgi_split_path_info ^(.+\.php)(/.+)$;
> try_files $uri =404;

If /usr/local/nginx/html/rus_example.php does not exist, that line
says "return 404", which the error_page line turns into a request for
/netcat/require/e404.php

f
--
Francis Daly francis@daoine.org
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx

Init script on Custom built nginx

$
0
0
Facing some problems after installing source built nginx
Installed using automatic pagespeed installer on NEW Ubuntu 16.04 (Clean install)
Doc Link : https://www.modpagespeed.com/doc/build_ngx_pagespeed_from_source

bash <(curl -f -L -sS https://ngxpagespeed.com/install) \
--nginx-version latest

i.e it is source built and not from ubuntu repo

root@xyz:~# vi "/usr/local/nginx/conf/nginx.conf"
root@xyz:~# vi "/usr/local/nginx/conf/nginx.conf"
root@xyz:~# nginx -t
The program 'nginx' can be found in the following packages:
* nginx-core
* nginx-extras
* nginx-full
* nginx-light
Try: apt install <selected package>
root@xyz:~# vi "/usr/local/nginx/conf/nginx.conf"
root@xyz:~# sudo service nginx restart
Failed to restart nginx.service: Unit nginx.service not found.
root@xyz:~# sudo /usr/sbin/nginx -V
sudo: /usr/sbin/nginx: command not found
root@xyz:~# sudo /usr/local/nginx -V
sudo: /usr/local/nginx: command not found
root@xyz:~# sudo /usr/local/nginx/sbin/nginx -V
nginx version: nginx/1.13.9
built by gcc 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.9)
configure arguments: --add-module=/root/incubator-pagespeed-ngx-latest-stable
root@xyz:~# sudo /usr/local/nginx/sbin/nginx restart
nginx: invalid option: "restart"
root@xyz:~# sudo service nginx restart
Failed to restart nginx.service: Unit nginx.service not found.
root@xyz:~# sudo systemctl restart nginx
Failed to restart nginx.service: Unit nginx.service not found.
root@xyz:~# sudo service nginx restart
Failed to restart nginx.service: Unit nginx.service not found.
root@xyz:~# /usr/local/nginx/sbin/nginx -s reload
nginx: [error] open() "/usr/local/nginx/logs/nginx.pid" failed (2: No such file or directory)
root@xyz:~# /usr/local/nginx/sbin/nginx start
nginx: invalid option: "start"
root@xyz:~# ps aux | grep nginx
root 20012 0.0 0.1 12944 1084 pts/0 S+ 06:50 0:00 grep --color=auto nginx


also i get only this when finding nginx

sudo find / -type f -name "nginx"
/usr/local/nginx/sbin/nginx
/root/nginx-1.13.9/objs/nginx



AFter Searching a lot on google finally i found that i need init script but still not sure which one to use
https://www.nginx.com/resources/wiki/start/topics/examples/initscripts/
linux init.d or upstart or systemd
and what i need to edit in those scripts

First time i have compiled nginx from source , so dont know much. earlier was using installing using apt-get

Re: nginx + php-fpm: REQUEST_URI disappears for files that end with .php

$
0
0
Hi Francis,

you are correct. You explained exactly what happens - thank you!


On Fri, 2018-03-09 at 00:01 +0000, Francis Daly wrote:
> On Thu, Mar 08, 2018 at 01:48:41PM +0200, ST wrote:
>
> Hi there,
>
> * What request do you make? (e.g. /rus_example.php)
> * Does the matching file exist on the filesystem
> (e.g. /usr/local/nginx/html/rus_example.php)?
> * If yes - what response do you want, and what response do you get?
> * If no - what response do you want, and what response do you get?
>
> > error_page 404 = /netcat/require/e404.php;
> >
> > location ~ \.php$ {
> > if ($args ~ "netcat_files/") {
> > expires 7d;
> > add_header Cache-Control "public";
> > }
> >
> > fastcgi_split_path_info ^(.+\.php)(/.+)$;
> > try_files $uri =404;
>
> If /usr/local/nginx/html/rus_example.php does not exist, that line
> says "return 404", which the error_page line turns into a request for
> /netcat/require/e404.php
>
> f

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

How to stop nginx from adding a trailing slash

$
0
0
Hello,

somesite.com/blog is 301 redirected to somesite.com/blog/ by nginx.

this is not the behaviour i want.

is there any way to stop it from doing so?


Thank you.

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

Re: How to stop nginx from adding a trailing slash

$
0
0
> On 9 Mar 2018, at 17:06, Gregory Edigarov <edigarov@qarea.com> wrote:
>
> Hello,
>
> somesite.com/blog is 301 redirected to somesite.com/blog/ by nginx.
>
> this is not the behaviour i want.
>
> is there any way to stop it from doing so?

A special location for "/blog":

location = /blog {
...
}

location /blog/ {
...
}


--
Igor Sysoev
http://nginx.com

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

Re: How to stop nginx from adding a trailing slash

$
0
0
On 09.03.18 16:52, Igor Sysoev wrote:
>> On 9 Mar 2018, at 17:06, Gregory Edigarov <edigarov@qarea.com> wrote:
>>
>> Hello,
>>
>> somesite.com/blog is 301 redirected to somesite.com/blog/ by nginx.
>>
>> this is not the behaviour i want.
>>
>> is there any way to stop it from doing so?
> A special location for "/blog":
>
> location = /blog {
> ...
> }
>
> location /blog/ {
> ...
> }
>
>
sorry, doesn't work...

It somehow seems to me, some time ago there was an option, to switch the
related behaviour.
but may be it is my false memory.
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx

Planned Features for gRPC Proxy

$
0
0
Hi all,

I am new to the nginx community so my apologies if this is not the correct place for this kind of question.

I see gRPC proxy is in progress for 1.13: https://trac.nginx.org/nginx/roadmap

Does anyone know if the proxy will support host/path based routing for gRPC calls? I have a use case in Kubernetes where I am trying to expose many gRPC microservices through a single nginx ingress controller. I’m trying to find out if context based routing will be supported so I can setup rules to be able to proxy to different services.

Thanks for the help,
-Ian_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx

Re: newbie: nginx rtmp module

$
0
0
I've resigned myself to the fact that there is no rtmp module here which leads me to the obvious question:

is it possible to install an rtmp module into this 'yum install' version of nginx?

Re: How to stop nginx from adding a trailing slash

$
0
0
> On 9 Mar 2018, at 19:17, Gregory Edigarov <edigarov@qarea.com> wrote:
>
> On 09.03.18 16:52, Igor Sysoev wrote:
>>> On 9 Mar 2018, at 17:06, Gregory Edigarov <edigarov@qarea.com> wrote:
>>>
>>> Hello,
>>>
>>> somesite.com/blog is 301 redirected to somesite.com/blog/ by nginx.
>>>
>>> this is not the behaviour i want.
>>>
>>> is there any way to stop it from doing so?
>> A special location for "/blog":
>>
>> location = /blog {
>> ...
>> }
>>
>> location /blog/ {
>> ...
>> }
>>
>>
> sorry, doesn't work...
>
> It somehow seems to me, some time ago there was an option, to switch the related behaviour.
> but may be it is my false memory.

It should work. 301 redirect is usually cached by browser for long time.
Try curl, another browser or try to clean cache.


--
Igor Sysoev
http://nginx.com

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

stream based on hostname

$
0
0
Hello!
here is my example of not working config

stream {
map $hostname $stream_destination {
hostname.com ip_address_1;
hostname2.com ip_address_2;
}
server {
listen 8080;
proxy_pass $stream_destination:8080;

}
}



i need to route tcp traffic based on hostname, help me to find out this please.

Re: newbie: nginx rtmp module

$
0
0
I believe you need to compile with the appropriate module. If this was freeBSD, no problem. Just use ports. (Of course FreeBSD has many other problems.) With centos, you will need to compile the code and use all the "with" options for each module you want to install. Potentially you will need to set up systemd to run your version of Nginx. It wouldn't surprise me that this is complicated enough that someone had already done a write up.

Regarding updating to Centos 7, if you are on VPS, you can easily image your Centos 6 installation should you get bogged down in the update. Or you set up a second VPS on a fresh install of centos 7 with a different domain name. That is how a currently do major changes. However I'm thinking I might set up DNS so that www1.example.com go to the experimental server. That would save the cost of owning an additional domain plus make it easier to deal with let'sencrypt.

I found this:

https://github.com/thonatos/notes/blob/master/backend-notes/install-and-conf-nginx-with-rtmp-on-Centos-7-64.md

This isn't up to date, but it is a start. Looking at the Nginx download page, they don't use git for source, but there is a mirror of sorts of the Nginx source on github. It would do that for both the source and module.

But the deal with Centos is you shouldn't be compiling code unless there is no other alternative. That is the idea is you do "yum update" and everything is secure. I don't go so far as to crontab the process, but some do. The point here being maybe there is some other way to rtmp without the module.

  Original Message  
From: nginx-forum@forum.nginx.org
Sent: March 9, 2018 8:59 AM
To: nginx@nginx.org
Reply-to: nginx@nginx.org
Subject: Re: newbie: nginx rtmp module

I've resigned myself to the fact that there is no rtmp module here which
leads me to the obvious question:

is it possible to install an rtmp module into this 'yum install' version of
nginx?

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,278950,278984#msg-278984

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

Re: newbie: nginx rtmp module

$
0
0
I had a few neurons fire. I forgot nginx can load dynamic modules.

https://www.nginx.com/blog/nginx-dynamic-modules-how-they-work/

I haven't done this myself, so you are on your own at this point.


On Fri, 09 Mar 2018 11:59:30 -0500
"neuronetv" <nginx-forum@forum.nginx.org> wrote:

> I've resigned myself to the fact that there is no rtmp module here
> which leads me to the obvious question:
>
> is it possible to install an rtmp module into this 'yum install'
> version of nginx?
>
> Posted at Nginx Forum:
> https://forum.nginx.org/read.php?2,278950,278984#msg-278984
>
> _______________________________________________
> nginx mailing list
> nginx@nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx

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

Re: newbie: nginx rtmp module

$
0
0
thanks again for your feedback on this thread and I see now I will have to strip out the 'yum install' and re-compile nginx like I did before. I was able to configure in the rtmp module using that method and video streaming worked. The 'aaaarrrgh' bit is just working out how to get the compiled install to serve multiple domains.

Re: newbie: nginx rtmp module

$
0
0
I believe you shouldn't have to compile Nginx but use the disty binary. Then you do the dynamic load trick. This way you can do "yum update" periodically without having to compile Nginx, but rather just download the latest binary.

However don't break what is working!


  Original Message  
From: nginx-forum@forum.nginx.org
Sent: March 10, 2018 1:08 AM
To: nginx@nginx.org
Reply-to: nginx@nginx.org
Subject: Re: newbie: nginx rtmp module

thanks again for your feedback on this thread and I see now I will have to
strip out the 'yum install' and re-compile nginx like I did before. I was
able to configure in the rtmp module using that method and video streaming
worked. The 'aaaarrrgh' bit is just working out how to get the compiled
install to serve multiple domains.

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,278950,278989#msg-278989

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

Re: newbie: nginx rtmp module

$
0
0
hi sorry but I'm not quite clear. You said 'you shouldn't have to compile Nginx but use the disty binary'. I'm not sure what the disty binary is. Do you mean installing from the nginx repo at http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm?
or from the latest tarball?

Re: newbie: nginx rtmp module

$
0
0
Yum install nginx
gets you the binary. I'm not really sure how the dynamic module load works, but my understanding (or perhaps lack thereof) means you supplement the precompiled binary with the module.

Solve your other problems first, then you can investigate this if you want to beat your head against the wall some more.

Once you figure the dynamic module load, you could do a post about how it works. I often do this just so I can find my old post if I have trouble doing the same thing a year or two later.

Presumably once you figure this out, your transition to Centos 7 will be easier.


  Original Message  
From: nginx-forum@forum.nginx.org
Sent: March 10, 2018 8:58 AM
To: nginx@nginx.org
Reply-to: nginx@nginx.org
Subject: Re: newbie: nginx rtmp module

hi sorry but I'm not quite clear. You said 'you shouldn't have to compile
Nginx but use the disty binary'. I'm not sure what the disty binary is. Do
you mean installing from the nginx repo at
http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm?
or from the latest tarball?

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,278950,278991#msg-278991

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

Re: newbie: nginx rtmp module

$
0
0
yes I've uninstalled nginx and reinstalled, this time using the nginx repo and it gave me a newer version but still no rtmp module to be seen. Fortunately I've solved my other problems but nginx is no good to me without rtmp as I have to do video streaming, this is my whole reason for migrating from apache to nginx. I'm struggling to understand the dynamic modules page (thanks for that link) and I'm not even sure it applies to a 'yum install' version as it refers to configuring the module into nginx during the build.

Re: proxy_pass and trailing / decode uri

$
0
0
Hello!

On Thu, Mar 08, 2018 at 10:34:36PM +0100, max wrote:

> Sorry if it was already asked but I'd like to know if the only way to
> prevent Nginx from decoding uri while using proxy_pass is:
> https://stackoverflow.com/a/37584656/3515745
>
> Here is my (simplified) conf:
>
> server {
> server_name domain1.com;
>
> location / {
> proxy_pass http://127.0.0.1:81;
>
> }
>
> location /api {
> proxy_pass http://127.0.0.1:82/;
>
> }
> }
>
> Location "/" is perfectly working. My problem is that "/api" location will
> decode special character.

When you want nginx to replace matching part of the URI with "/",
it will do so on the decoded/normalized URI, and will re-encode
special characters in what's left.

If you want nginx to preserve original URI as sent by the client,
consider using proxy_pass without the URI part. That is,
instead of

proxy_pass http://127.0.0.1:82/;

use

proxy_pass http://127.0.0.1:82;

Note no trailing "/". This way the original URI as sent by the
client will be preserved without any modifications.

--
Maxim Dounin
http://mdounin.ru/
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Viewing all 53287 articles
Browse latest View live


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