By brenda
I have everything set up with my sudoer account on my Ubuntu VPS, e.g. /ghost directory and sub content owned by sudoer account. I’ve added my domain to the ocean domain DNS and can ping my domain and get back my server’s IP, so this is working fine. I had configured Ghost first, so I am able to get to my site via the IP:2368 and domain:2368 fine, but I wanted to use the nginx proxy server, so I could access it via port 80. Therefore, I setup nginx, I started the service, and when I got to my site (e.g. site.com), I get “502 Bad Gateway”. When looking at the errors logs, I see the following:
2014/05/17 16:40:40 [error] 29645#0: *21 connect() failed (111: Connection refused) while connecting to upstream, client: XX.XXX.XXX.XXX, server: site.com request: “GET / HTTP/1.1”, upstream: “http://127.0.0.1:2368/”, host: “site.com”
I can see nginx is running:
sudo service nginx status
The nginx config file contains the usual:
server { listen 0.0.0.0:80; server_name my-domain-name; access_log /var/log/nginx/my-domain-name.log;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header HOST $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://127.0.0.1:2368;
proxy_redirect off;
}
}
My sudoer account is a member of www-data, so my /ghost folder is owned by the sudoer and the www-data group. Both have read, write and execute permissions to all the folders and files in /ghost only. Do I need to change permissions anywhere else for this to work? I’ve been reading other people’s problems with error 502 and they all seem to solve them by changing permissions on their /ghost directory, but I think they are using root and that is not my case.
Note: I get the same error if I log in a root, restart nginx, and load my page, or if I log in as sudoer, restart nginx, and load my page.
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!
Hello Everyone, <br> <br>I wanted to share that I found the issue. When setting up my blog, I initially set it up, so that I could run Ghost with npm and access the blog via my server’s IP address and domain name, so I had changed this in the config.js file. However, I did not want to have to use the the Ghost port 2368, so I installed the nginx proxy server, so that i could re-direct requests on port 80 to 2368. Once nginx was configured, I was getting the Gateway error because both ghost and nginx where now listening at different ports and nginx was redirecting to the server’s localhost address at port 2368. The problem here was the Ghost’s config.js was still using the server’s IP, rather than the localhost address. Anyways, once I change the Ghost config.js file’s “host” address back to the localhost 127.0.0.1, everything worked. In case anyone has this problem and want’s to see how I got it working, you can check my post at http://thehme.com/2014/05/24/ghost-blog-on-ubuntu-with-nginx/ <br> <br>
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.