website/admin behind my reverse proxy doesn't work
Maxim Dounin
mdounin at mdounin.ru
Thu Dec 29 23:37:04 UTC 2022
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/
More information about the nginx
mailing list