Welcome! Log In Create A New Profile

Advanced

Re: website/admin behind my reverse proxy doesn't work

Maxim Dounin
December 29, 2022 06:38PM
Hello!

On Wed, Dec 28, 2022 at 11:01:11PM +0000, Mik J via nginx wrote:

> Hello,
> I have a website hosted on a server using nginx behind a nginx
> reverse proxy but things don't work properly.
> https://mywebsite.org => works
> https://mywebsite.org/admin => doestn't work it redirects to https://mywebsite.org
>
> On my backend serverserver {
>         listen 80;
>         server_name mywebsite.org ;
>         index index.php;
>         root /var/www/htdocs/sites/mywebsite;...
>         location / {
>           try_files $uri $uri/ /index.php$is_args$args;
>
>           location ~ \.php$ {
>               root           /var/www/htdocs/sites/mywebsite;
>               try_files $uri =404;
>               fastcgi_pass   unix:/run/php-fpm.mywebsite.org.sock;
>               fastcgi_split_path_info ^(.+\.php)(/.+)$;
>               fastcgi_index  index.php;
>               fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
>               include        fastcgi_params;
>           }
>         }}
> On my reverse proxyserver {
> #    listen 80;
> #    listen [::]:80;
>     listen 443 ssl;
>     listen [::]:443 ssl;
>     server_name http://mywebsite.org;...
>     root /var/www/htdocs/mywebsite;
>     location ^~ / {
>         proxy_pass              http://10.12.255.23:80;
>         proxy_redirect          off;
>         proxy_set_header        Host    $host;
>         proxy_http_version 1.1;
>         proxy_set_header  X-Real-IP        $remote_addr;
>         proxy_set_header  X-Forwarded-Host $host;
>         proxy_set_header  X-Forwarded-For  $proxy_add_x_forwarded_for;
>         proxy_set_header        Referer         "http://mywebsite.org/";
>         proxy_pass_header Set-Cookie;
>         proxy_set_header  X-Forwarded-Proto $scheme;
>     }
> }
>
>
> So I can't access
>
> In the backend server logs I see
> [28/Dec/2022:23:54:33 +0100] "GET /admin/ HTTP/1.1" 302 5 "http://mywebsite.org/" ...
> [28/Dec/2022:23:54:33 +0100] "GET / HTTP/1.1" 499 0 "http://mywebsite.org/" ...

In your nginx configurations no redirects are returned.
Accordingly, it looks like redirects you are seeing are returned
by the backend's PHP code. To find out why these are returned
you'll probably have to look into the PHP code.

--
Maxim Dounin
http://mdounin.ru/
_______________________________________________
nginx mailing list
nginx@nginx.org
https://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

website/admin behind my reverse proxy doesn't work

Mik J via nginx December 28, 2022 06:02PM

Re: website/admin behind my reverse proxy doesn't work

Maxim Dounin December 29, 2022 06:38PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 108
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready