Nginx and proxy_pass ip

i’ve got little problem with nginx and proxy_pass on my VPS, the configuration look like this:

server {

    listen 8080;
    root /var/www/;
    index index.php;

    location ~ .php {
            fastcgi_split_path_info ^(.+.php)(/.+)$;
            fastcgi_pass wordpress;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME   $document_root$fastcgi_script_name;
            fastcgi_param QUERY_STRING      $query_string;
            include fastcgi_params;
    }

}

Read More
server {
    listen 80;
    root /var/www;
    index index.html;

    location ~ ^/mihal {
            proxy_pass http://127.0.0.1:8080;
    }

    location ~ .php {
            fastcgi_split_path_info ^(.+.php)(/.+)$;
            fastcgi_pass wordpress;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME   $document_root$fastcgi_script_name;
            fastcgi_param QUERY_STRING      $query_string;
            include fastcgi_params; 
    }

}

and every time i’ve try to get the http://serverdomanin.com/mihal i’ve been redirected to http://127.0.0.1/mihal
What should i moderate to corectly use this configuration? (under /mihal/ is wordpress instance).
Many thanks for help!

Related posts

1 comment

  1. The redirect is generated by the service running on port 8080, which does not know the name serverdomain.com.

    You can rewrite the redirect using the proxy_redirect directive.

    Try this:

    location ~ ^/mihal {
        proxy_pass http://127.0.0.1:8080;
        proxy_redirect http://localhost/ http://$host/;
        proxy_redirect http://localhost:8080/ http://$host/;
    }
    

    See this document for details.

Comments are closed.