I am getting a 502 bad gateway error while running discourse alongside linux. It is currently the only website I have running on my machine.
Here is the error I get when I use tail -f /var/log/nginx/error.log
:
2015/04/08 21:03:13 [error] 8436#0: *6 connect() failed (111: Connection refused) while connecting to upstream, client: 173.245.54.87, server: epicdinosaurz.net, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:3000/", host: "epicdinosaurz.net"
Here is my disco.conf in nginx:
types {
text/csv csv;
}
upstream discourse { server 127.0.0.1:3000; }
proxy_cache_path /var/nginx/cache keys_zone=one:10m max_size=200m;
map $http_x_forwarded_proto $thescheme {
default $scheme;
https https;
}
limit_req_zone $binary_remote_addr zone=flood:10m rate=13r/s;
limit_req_zone $binary_remote_addr zone=bot:10m rate=222r/m;
limit_req_status 429;
server {
listen 80;
gzip on;
gzip_vary on;
gzip_min_length 987;
gzip_comp_level 5;
gzip_types application/json text/css application/x-javascript application/javascript;
server_name epicdinosaurz.net;
server_tokens off;
sendfile on;
keepalive_timeout 66;
client_max_body_size 10m ;
set $public /var/www/discourse/public;
add_header X-UA-Compatible "IE=edge";
etag off;
location ^~ /backups/ {
internal;
}
location / {
root $public;
add_header ETag "";
location ~* \.(eot|ttf|woff|ico)$ {
expires 1y;
add_header Cache-Control public;
add_header Access-Control-Allow-Origin *;
}
location ~ ^/assets/ {
expires 1y;
gzip_static on;
add_header Cache-Control public;
break;
}
location ~ ^/plugins/ {
expires 1y;
add_header Cache-Control public;
}
location ~ /_?emoji/ {
expires 1y;
add_header Cache-Control public;
}
location ~ ^/uploads/ {
proxy_set_header Host $http_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 $thescheme;
proxy_set_header X-Sendfile-Type X-Accel-Redirect;
proxy_set_header X-Accel-Mapping $public/=/downloads/;
expires 1y;
add_header Cache-Control public;
location ~ /stylesheet-cache/ {
try_files $uri =404;
}
location ~* \.(gif|png|jpg|jpeg|bmp|tif|tiff)$ {
try_files $uri =404;
}
location ~ /_optimized/ {
try_files $uri =404;
}
proxy_pass http://discourse;
break;
}
location ~ ^/admin/backups/ {
proxy_set_header Host $http_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 $thescheme;
proxy_set_header X-Sendfile-Type X-Accel-Redirect;
proxy_set_header X-Accel-Mapping $public/=/downloads/;
proxy_pass http://discourse;
break;
}
try_files $uri @discourse;
}
location /downloads/ {
internal;
alias $public/;
}
location @discourse {
limit_req zone=flood burst=13 nodelay;
limit_req zone=bot burst=103 nodelay;
proxy_set_header Host $http_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 $thescheme;
proxy_pass http://discourse;
}
}
and here is my discourse.conf in /var/www/discourse:
# Discourse supports multiple mechanisms for production config, detailed in the _defaults file.
# This file includes the most commonly changed enviroment variables, to allow users following the official install guide to quickly get started; if the option you're looking for is not here it may be defined in the _defaults file.
# Change the following!
# All settings apply to production only
# database name running discourse, in INSTALL-ubuntu this is discourse_prod
db_name = discourse_prod
# hostname running the forum; i.e the external address of your form.
hostname = "www.epicdinosaurz.net"
# address of smtp server used to send emails. If testing, this can be left empty; but e-mails are a very important part of discourse.
smtp_address = smtp.mandrillapp.com
# port of smtp server used to send emails. This varies based on your e-mail host.
smtp_port = 587
# domain passed to smtp server
smtp_domain =
# username for smtp server
smtp_user_name = notify@epicdinosaurz.net
# password for smtp server
smtp_password = Not gonna put this here for the world to see ;)
# enable TLS encryption for smtp connections
smtp_enable_start_tls = true
# enable MiniProfiler for developers, by default this is true. This shows response times in the top left for admin users only. Uncomment this line to turn this off.
# load_mini_profiler = false
# recommended, cdn used to access assets. This can be left empty at first.
cdn_url =
# comma delimited list of emails that have developer level access.
developer_emails = email redacted
# More advanded settings. Unless you changed these in your enviroment, the defaults will work.
## Database
# host address for db server, uncomment if needed
# db_host = localhost
# port running db server, uncomment if needed
# db_port = 5432
# username accessing database, if connecting remotely
# db_username = discourse
# password used to access the db, if connecting remotely
# db_password =
# Redis
# redis server address
# redis_host = localhost
# redis server port
# redis_port = 6379
# redis password
# redis_password =