我正在尝试使用nginx将Ruby API安装在AWS服务器上。 而且我有一个问题,nginx找不到我的某些路(在本地效果很好)。
但是它找到了存在于address_server / v1 / test路径中的一个,而不是存在于address_server / test中的一个。
有人知道这可能来自哪里吗?
感谢您抽出宝贵的时间!
Route.rb
Rails.application.routes.draw do
devise_for :admin_users, ActiveAdmin::Devise.config
ActiveAdmin.routes(self)
post 'user_token' => 'user_token#create'
post 'user_fb_token' => 'user_fb_token#fb_create'
namespace :api_v1, path: :v1, defaults: { format: :json } do
DEFAULT_API_V1_OPTS = {only: [:index, :show, :create, :update, :destroy], defaults: { format: :json }}.freeze
post 'dislike', to: 'likes#delete', defaults: { format: :json }
resources :likes, only: [:index, :show, :create, :update]
post 'unwish', to: 'wishes#delete', defaults: { format: :json }
resources :wishes, DEFAULT_API_V1_OPTS
resources :notes, DEFAULT_API_V1_OPTS
get 'products/wished', to: 'products#wished', defaults: { format: :json }
resources :products, DEFAULT_API_V1_OPTS
resources :categories, DEFAULT_API_V1_OPTS
resources :happies, DEFAULT_API_V1_OPTS
get 'selfies/liked', to: 'selfies#liked', defaults: { format: :json }
get 'selfies/me', to: 'selfies#show_me', defaults: { format: :json }
resources :selfies, DEFAULT_API_V1_OPTS
get 'selfies/:id/fb_share', to: 'selfies#fb_share', defaults: { format: :json }
get 'users/notify', to: 'users#notify_me', defaults: {format: :json}
get 'users/me', to: 'users#show_me', defaults: { format: :json }
put 'users/me', to: 'users#update_me', defaults: { format: :json }
resources :users, DEFAULT_API_V1_OPTS
get 'users/:id/request_friends', to: 'users#request_friends', defaults: { format: :json }
get 'users/request_friends_callback', to: 'users#request_friends_callback', defaults: { format: :json }
post 'users/:id/register_device', to: 'users#register_device', defaults: { format: :json }
resources :reports, DEFAULT_API_V1_OPTS
end
end
nginx配置:
upstream thin {
server 127.0.0.1:3000;
}
server {
listen 80;
server_name 52.47.133.83;
root /home/ubuntu/happer-api/public;
location / {
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;
proxy_redirect off;
if (-f $request_filename/index.html) {
rewrite (.*) $1/index.html break;
}
if (-f $request_filename.html) {
rewrite (.*) $1.html break;
}
if (!-f $request_filename) {
proxy_pass http://thin;
break;
}
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
更新资料
邮递员回溯
Server →nginx/1.14.0 (Ubuntu)
Date →Wed, 22 May 2019 21:21:43 GMT
Content-Type →text/html
Transfer-Encoding →chunked
Connection →keep-alive
X-Frame-Options →SAMEORIGIN
X-XSS-Protection →1; mode=block
X-Content-Type-Options →nosniff
Cache-Control →no-cache
X-Request-Id →a65170fb-21e9-4e21-932a-f1ef554c94c3
X-Runtime →0.079642
Content-Encoding →gzip
nginx错误日志:
2019/05/23 10:48:29 [error] 15887#15887: *34 connect() failed (111: Connection refused) while connecting to upstream, client: 109.210.187.167, server: 52.47.133.83, request: "POST /user_token HTTP/1.1", upstream: "http://127.0.0.1:3000/user_token", host: "52.47.133.83"