Uri_for enables port forwarding

I am trying to deploy a Catalyst application using nginx as a web proxy for static files and using Starman for my backend server. (I could use Apache and FastCGI, and it works fine, but I would really like all PSGI / Plack and Starman to disappear)

Starman starts up well and can handle my requests perfectly http://localhost:5000. When I run nginx to use as my external proxy, my urls get ugly and cripple with a port number (5000) whenever I use the method $c->uri_for.

Example:

$ c-> uri_for ("/ login")
becomes
http://myapp.example.comโ–บ000/login 
rather than
http://myapp.example.com/login 

I have created several magazines, so I see that X-Forwarded-Hostthey are X-Forwarded-Forinstalled as. For regular queries, there are values โ€‹โ€‹set (starting with nginx), but whenever the method is used $c->uri_for, these values โ€‹โ€‹do not exist.

Has anyone else had this problem?
Am I missing something else in my nginx configuration or my Catalyst conf?

Thank!

nginx config:

server {
        listen 80;
        server_name myapp.example.com;

        location / static {
            root / data / users / MyApp / root;
            expires 30d;
        }

        location / {
            proxy_set_header Host $ host;
            proxy_set_header X-Forwarded-Host $ host;
            proxy_set_header X-Real-IP $ remote_addr;
            proxy_set_header X-Forwarded-For $ proxy_add_x_forwarded_for;

            proxy_pass http://localhost:5000/;
        }
    }

, , MyApp, :

MyApp->config(using_frontend_proxy => 1)

:

Catalyst : 5.80024
nginx : 0.7.67
Plack : 0.9942
Starman : 0.2006
+3
2

myapp.psgi .

Catalyst:: Engine:: PSGI Plack::Middleware::ReverseProxy:

...
use Plack::Builder;
use MyApp;

MyApp->setup_engine('PSGI');
my $app = sub { MyApp->run(@_) };

builder {
 enable_if { $_[0]->{REMOTE_ADDR} eq '127.0.0.1' } 
        "Plack::Middleware::ReverseProxy";
 $app;
};
+4

MyApp->config(using_frontend_proxy => 1)

.

+1

Source: https://habr.com/ru/post/1756962/


All Articles