app mvc behind proxy reverse

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

app mvc behind proxy reverse

Ricky Gutierrez
Hi, I am having some problems to load an app made in mvc, when I
access the url and I want to edit a table to make a change, the proxy
returns me to the root of the project, and it does not stay in
app/pais

I paste the url log, where it says it can't find resource 404

https://pastebin.com/AeRRrMRi

1.1.1.1 - - [05/Aug/2020:17:21:23 -0600] "POST /agregareditar
HTTP/2.0" 404 709 "https://test.domain.com/pais" "Mozilla/5.0
(Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/605.1.15 (KHTML, like
Gecko) Version/13.1.2 Safari/605.1.15"

proxy reverse config:



location / {

        proxy_http_version 1.1;
        proxy_set_header Connection "";
        proxy_set_header Host $host;
proxy_set_header X-Real-IP  $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  proxy_connect_timeout 900s;
        proxy_send_timeout 900s;
        proxy_read_timeout 900s;
proxy_buffer_size 64k;
proxy_buffers 16 32k;
proxy_busy_buffers_size 64k;
proxy_redirect off;
proxy_request_buffering off;
proxy_buffering off;
        proxy_pass http://backend29;
}


=== backend config

upstream backend29 {

    server 192.168.11.95:80; ## web windows

    keepalive 2;

}

server {

listen 80;

        server_name test.domain.com; #YourIP or domain

pagespeed unplugged;

        return 301 https://$server_name$request_uri;  # redirect all to use ssl


    }


any ideas?


--
rickygm

http://gnuforever.homelinux.com
_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: app mvc behind proxy reverse

Francis Daly
On Wed, Aug 05, 2020 at 05:31:26PM -0600, Rick Gutierrez wrote:

Hi there,

> Hi, I am having some problems to load an app made in mvc, when I
> access the url and I want to edit a table to make a change, the proxy
> returns me to the root of the project, and it does not stay in
> app/pais

Your nginx config says that when the client asks nginx for
/pais/agregareditar, nginx asks the upstream for /pais/agregareditar --
your log at "05/Aug/2020:17:20:51" shows this request.

Your nginx config says that when the client asks nginx for
/agregareditar, nginx asks the upstream for /agregareditar -- your log at
"05/Aug/2020:17:21:23" shows this request.

It looks like the app is pointing to /agregareditar instead of to
/pais/agregareditar; and it looks like nginx is not involved in this.


Can you see what the html-or-javascript that tells the browser where to
POST the request, says about where to POST the request?

> any ideas?

Maybe something like "location = /pais { return 301 /pais/; }" in
your nginx config will help, if the upstream server should do that but
does not?

Good luck with it,

        f
--
Francis Daly        [hidden email]
_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: app mvc behind proxy reverse

Ricky Gutierrez
El jue., 6 ago. 2020 a las 6:29, Francis Daly (<[hidden email]>) escribió:
>

Hi francis

>
> Your nginx config says that when the client asks nginx for
> /pais/agregareditar, nginx asks the upstream for /pais/agregareditar --
> your log at "05/Aug/2020:17:20:51" shows this request.
>
> Your nginx config says that when the client asks nginx for
> /agregareditar, nginx asks the upstream for /agregareditar -- your log at
> "05/Aug/2020:17:21:23" shows this request.
>
> It looks like the app is pointing to /agregareditar instead of to
> /pais/agregareditar; and it looks like nginx is not involved in this.
>
>

> Can you see what the html-or-javascript that tells the browser where to
> POST the request, says about where to POST the request?

The country file, is a javascript, performs the task, only that url
that calls is where the controller is, that verifies if it edits or
saves, and the proxy reverse does not interpret it that way because it
is only a folder address, not a file address per that's it send a 404.

I am not a programmer, the country folder has several files.

# Pais ls

AgregarEditar.cshtml ListaPaises.cshtml

Index.cshtml         Pais.txt


>
> > any ideas?
>
> Maybe something like "location = /pais { return 301 /pais/; }" in
> your nginx config will help, if the upstream server should do that but
> does not?

a little slower here, this would have to go down to the first
location, so what you tell me:

location = /pais { return 301 /pais/; }"





>
> Good luck with it,
>
>         f

thank



--
rickygm

http://gnuforever.homelinux.com
_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: app mvc behind proxy reverse

Francis Daly
On Thu, Aug 06, 2020 at 09:48:55AM -0600, Rick Gutierrez wrote:
> El jue., 6 ago. 2020 a las 6:29, Francis Daly (<[hidden email]>) escribió:

Hi there,

> > Can you see what the html-or-javascript that tells the browser where to
> > POST the request, says about where to POST the request?
>
> The country file, is a javascript, performs the task, only that url
> that calls is where the controller is, that verifies if it edits or
> saves, and the proxy reverse does not interpret it that way because it
> is only a folder address, not a file address per that's it send a 404.

As I understand it, your nginx conf says (basically)

  location / {
    proxy_pass http://backend29;
  }

so every request to nginx gets sent to the backend server. nginx does
not know or care about files or folders; it proxy_pass:es all requests.

So the 404 comes from the backend server, because the app causes the
browser to ask for /agregareditar and not for /pais/agregareditar.

> I am not a programmer, the country folder has several files.
>
> # Pais ls
>
> AgregarEditar.cshtml ListaPaises.cshtml
>
> Index.cshtml         Pais.txt
>
>
> >
> > > any ideas?
> >
> > Maybe something like "location = /pais { return 301 /pais/; }" in
> > your nginx config will help, if the upstream server should do that but
> > does not?
>
> a little slower here, this would have to go down to the first
> location, so what you tell me:
>
> location = /pais { return 301 /pais/; }"

My guess is that your browser's first request is for "/pais",
and that returns something from the backend that says "ask for
agregareditar". And the browser correctly resolves "/pais" +
"agregareditar" to "/agregareditar". But that is not what you want.

My guess is that if your browser's first request is for "/pais/" (with
a / at the end), then what is returned from the backend will be the
same; but now the browser will resolve "/pais/" + "agregareditar" to
"/pais/agregareditar", which (hopefully) is what you want.

If that does work -- if you start by asking for "/pais/" and everything
works as you want it to -- then you can tell nginx to intercept the first
request for "/pais", and tell the browser to instead ask for "/pais/". And
then things might work.

You can tell nginx to do that one-interception by putting

  location = /pais { return 301 /pais/; }

in the same file as your main config, just before the

  location / {

line that you showed.

If your application does *not* work when you start by requesting "/pais/",
then this change to nginx will not fix things for you.

Right now, I see no evidence of a problem in the nginx config; only in
the backend application.

Maybe some evidence will appear, if there is still a problem.

Good luck with it,

        f
--
Francis Daly        [hidden email]
_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: app mvc behind proxy reverse

Ricky Gutierrez
Thank Francis, if you're right, it's a backend problem.

we are solving.

El El jue, 6 de ago. de 2020 a la(s) 10:25, Francis Daly <[hidden email]> escribió:
On Thu, Aug 06, 2020 at 09:48:55AM -0600, Rick Gutierrez wrote:

> El jue., 6 ago. 2020 a las 6:29, Francis Daly (<[hidden email]>) escribió:



Hi there,



> > Can you see what the html-or-javascript that tells the browser where to

> > POST the request, says about where to POST the request?

>

> The country file, is a javascript, performs the task, only that url

> that calls is where the controller is, that verifies if it edits or

> saves, and the proxy reverse does not interpret it that way because it

> is only a folder address, not a file address per that's it send a 404.



As I understand it, your nginx conf says (basically)



  location / {

    proxy_pass http://backend29;

  }



so every request to nginx gets sent to the backend server. nginx does

not know or care about files or folders; it proxy_pass:es all requests.



So the 404 comes from the backend server, because the app causes the

browser to ask for /agregareditar and not for /pais/agregareditar.



> I am not a programmer, the country folder has several files.

>

> # Pais ls

>

> AgregarEditar.cshtml ListaPaises.cshtml

>

> Index.cshtml         Pais.txt

>

>

> >

> > > any ideas?

> >

> > Maybe something like "location = /pais { return 301 /pais/; }" in

> > your nginx config will help, if the upstream server should do that but

> > does not?

>

> a little slower here, this would have to go down to the first

> location, so what you tell me:

>

> location = /pais { return 301 /pais/; }"



My guess is that your browser's first request is for "/pais",

and that returns something from the backend that says "ask for

agregareditar". And the browser correctly resolves "/pais" +

"agregareditar" to "/agregareditar". But that is not what you want.



My guess is that if your browser's first request is for "/pais/" (with

a / at the end), then what is returned from the backend will be the

same; but now the browser will resolve "/pais/" + "agregareditar" to

"/pais/agregareditar", which (hopefully) is what you want.



If that does work -- if you start by asking for "/pais/" and everything

works as you want it to -- then you can tell nginx to intercept the first

request for "/pais", and tell the browser to instead ask for "/pais/". And

then things might work.



You can tell nginx to do that one-interception by putting



  location = /pais { return 301 /pais/; }



in the same file as your main config, just before the



  location / {



line that you showed.



If your application does *not* work when you start by requesting "/pais/",

then this change to nginx will not fix things for you.



Right now, I see no evidence of a problem in the nginx config; only in

the backend application.



Maybe some evidence will appear, if there is still a problem.



Good luck with it,



        f

--

Francis Daly        [hidden email]

_______________________________________________

nginx mailing list

[hidden email]

http://mailman.nginx.org/mailman/listinfo/nginx

--

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx