Related to reverse proxy

hello ,
i am installing ghost in ec2 ubuntu server without ssl and i want to access it to via reverse proxy with my second server https://example.com/blogs and in also ghost server i give same https://example.com/blogs url but it gives time-out 502 Bad Gateway
how can i resolve this please suggest me

If you want help, you’re going to need to share much more information about your configuration.

1 Like

You can’t deliver different sites to the same URL. Maybe you typed wrong? You could have https://mysite.com and https://blog.mysite.com or https://mysite.com and https://mysite.com/blog.

More detail is needed.

It gives multiple redirects error

What kind of info i am share for this?

What the reverse proxy is, and the configuration file (minus any secrets) for it would be a good place to start.

GNU nano 7.2 jobsyahan.com.conf
server {
listen 80;
listen [::]:80;

server_name _;
root /var/www/jy-blogs/system/nginx-root; # Used for acme.sh SSL verification (https://acme.sh)

location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_pass http://127.0.0.1:2368;
proxy_redirect off;
}

location ~ /.well-known {
    allow all;
}

client_max_body_size 50m;
}

this is for ghost server

location /blogs {
proxy_pass http://44.199.84.215:2368;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;

# Fix for infinite redirect loop
proxy_set_header X-Forwarded-Host $host;

proxy_redirect off;
}

and this one is for second server where i want to request via domain

You’re still not sharing sufficient information about the two sites. However, one observation: the first site runs on the local machine, but the other does not. Is this correct?

Moreover, do not use proxy_redirect off. It’s unnecessary as proxy_pass does what you need.

But please provide details for each sites, including the CMS, host etc.

First site is running on aws ec2 instance second site is running on other aws ec2 instance i want to access with my second server https://sites.com/blogs and i want to point this to my ghost server which is running on first server

OK, maybe I can help. You want to proxy the /blog directory on server1.com/blog to pull the Ghost blog from server2.com. It’s a little bit of a challenge.

On server 1 use this nginx config.
You also have to sort out the SSL certificates.

On server2.com use the standard Ghost config and let Ghost run in root.
Possibly you have to tell Ghost that it’s running in a sub directory.

    server {
        listen 80;
        server_name example.com;

        location /blog {
            proxy_pass http://example2.com;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection 'upgrade';
            proxy_cache_bypass $http_upgrade;
        }
    }
}

this is my ghost config
{
“url”: “https://jobsyahan.com/blogs”,
“server”: {
“port”: 2368,
“host”: “127.0.0.1”
},
}

You’re still only drip feeding information. Are both sites running Ghost? Why do both sites use tge same port? Please make it clear what config relates to each site.

Likewise, is the proxy only on one server? Where you specified an IP address, is the port open for the remote host?

Let me explain you ,

I have two server
first is where ghost is running without ssl
And in ghost blog config i have given blog url https://example.com/blogs

In second server my project is running https://example.com i want to access (ghost server) via https://example.com/blogs

When /blogs given endpoint i want to access my ghost blog please suggest me what can i do for it