【发布时间】:2023-03-12 18:18:01
【问题描述】:
现在我在 Amacon EC2 上成功配置了一个 rails 应用程序。我成功配置了 nginx 和 unicorn,现在我可以看到这个 url 为myipaddress/login但想使用域名访问。
这是问题,因为我已经更改了 hosts 文件并在 ec2 实例中的 ssh 之后添加了以下内容:-
127.0.0.1 www.mysite.com
#Virtual Hosts
myipaddress www.mysite.com
myipaddress mysite.com
我的/home/ubuntu/shareit/config/nginx.conf 文件也是这样的:-
upstream unicorn {
server unix:/home/ubuntu/shareit/tmp/sockets/unicorn.shareit.sock fail_timeout=0;
}
server {
listen 80;
#listen [::]:80 ipv6only=on default_server;
server_name mysite.com www.mysite.com;
root /home/ubuntu/shareit/public;
access_log /home/ubuntu/shareit/log/access.log;
error_log /home/ubuntu/shareit/log/error.log;
location ^~ /assets/ {
gzip_static on;
expires max;
add_header Cache-Control public;
}
try_files $uri/index.html $uri @unicorn;
location @unicorn {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://unicorn;
}
error_page 500 502 503 504 /500.html;
client_max_body_size 4G;
keepalive_timeout 10;
}
但当我尝试点击 url www.mysite.com 而不是 myipaddress/login(正在工作)时,我仍然会收到错误,因为 此网页不可用。
所以我错过了什么吗?我不想使用 ipaddress 访问我的应用程序。我什至尝试在 routes.rb 中使用应用程序名称,但它仍然无法正常工作。
我什至使用sudo /etc/init.d/nscd restart 刷新了 UBUNTU dns 并重新启动了 nginx 和 unicorn,但它不起作用?
任何帮助将不胜感激?
【问题讨论】:
标签: ruby-on-rails ubuntu nginx amazon-ec2 unicorn