Use nginx reverse proxy for redirection

Solution 1:

Simply send the right Host header to your proxy target by removing the proxy_set_header Host $http_host line.

If a.b is configured as a server name in your server block then you don't even need proxy_redirect directive if you use a trailing slash in your location prefix and in your proxy_pass target as explained in the documentation :

Syntax:  proxy_redirect default;
         proxy_redirect off;
         proxy_redirect redirect replacement;
Default: proxy_redirect default;
Context: http, server, location

[ ...]

The default replacement specified by the default parameter uses the parameters of the location and proxy_pass directives. Hence, the two configurations below are equivalent:

location /one/ {
    proxy_pass     http://upstream:port/two/;
    proxy_redirect default;
}

location /one/ {
    proxy_pass     http://upstream:port/two/;
    proxy_redirect http://upstream:port/two/ /one/;
}

[ ....]

So, this should do it :

server {

    server_name a.b;

    location /c/ {       
        proxy_pass http://username.github.io/project/;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_buffering off;
    }

}