I'm trying to set my rails app to a specific subdomain. I'm using an ec2 instance with a bitnami rubystack VM I developed the app using it with the ip of the server, so I know that rails and the app work.
${nginx-dir}/conf/nginx.conf
server {
listen 80 default_server;
server_name _;
server_name_in_redirect off;
proxy_intercept_errors on;
return 401;
}
include "/opt/bitnami/nginx/conf/vhosts/*.conf";
${nginx-dir}/conf/vhosts/backend.conf
upstream thin_instances {
server 0.0.0.0:3000;
server 0.0.0.0:3001;
server 0.0.0.0:3002;
fair;
}
server {
# port to listen on. Can also be set to an IP:PORT
listen 80;
server_name backend.mydomain.com;
root /opt/bitnami/projects/myappname/public;
location / {
proxy_pass http://thin_instances;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
if (!-f $request_filename) {
proxy_pass http://thin_instances;
break;
}
}
}
This is what I get when I do a post or get request to the domain
<html>
<head><title>401 Authorization Required</title></head>
<body bgcolor="white">
<center><h1>401 Authorization Required</h1></center>
<hr><center>nginx/1.2.4</center>
</body>
</html>