Proxy_Pass works when accessed directly but gives HTTP 400 when linked

I’m using the Ghost droplet to host a blog which is linked from Proxy pass has it setup at This links works perfectly if I enter it into my URL bar and access it directly. However there is a link on’s homepage. The link is to but for some reason my nginx configuration tries to 301 redirect it to This then returns HTTP 400 “The plain HTTP request was sent to HTTPS port”

I have played around with this for the last 2 days and cant figure out what’s causing this. Seeing as the proxy_pass works fine it has to be something to do with the http redirect right? But i cant see any issues with it. I’m sure its something staring me right in the face!

worker_processes  1;

events {
    worker_connections  1024;

http {
include       mime.types;
default_type  application/octet-stream;
sendfile        on;
keepalive_timeout  65;

    listen 80;
    listen 443; 

    return 301;


server {
    listen 80;
    listen 443; 

    if ($http_x_forwarded_proto = 'http'){
        return 301 https://$host$request_uri;

    sendfile on;

    default_type application/octet-stream;

    gzip on;
    gzip_http_version 1.1;
    gzip_disable      "MSIE [1-6]\.";
    gzip_min_length   256;
    gzip_vary         on;
    gzip_proxied      expired no-cache no-store private auth;
    gzip_types        text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript;
    gzip_comp_level   9;

    root /usr/share/nginx/html;

    location / {
        try_files  $uri $uri/ /blog/$uri;

    location /blog/ {
        proxy_pass https://ip.address:443;
        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;



include servers/*;

Submit an answer
Answer a question...

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Accepted Answer

Remove the 443 port from your /blog/ location. That’s redundant (you already specified https) and could be causing issues. and add “port_in_redirect off;” to your server block.