Rails' * _url with a custom port (not 80). (Nginx, Unicorn)

I am noob in the rails workspace. Can I configure nginx and unicorn to respond on a different (not 80) port? I do not need any domains, I only need ip and port. Here is the nginx configuration for my application (80 ports):

server {
    listen 80;
    server_name  localhost;
    root /home/my_app_folder/web-app/public;
    client_max_body_size 32m;
    location / {
        try_files  $uri @unicorn;
    }
    location @unicorn {
        proxy_set_header  Client-Ip $remote_addr;
        proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header  Host $host;
        proxy_pass  http://unix:/home/my_app_folder/web-app/tmp/sockets/unicorn.sock;
    }
}

My application works fine with 80 ports. If I change, for example, 80-3000, for example:

server {
    listen 3000;
    server_name  localhost;
    root /home/my_app_folder/web-app/public;
    client_max_body_size 32m;
    location / {
        try_files  $uri @unicorn;
    }
    location @unicorn {
        proxy_set_header  Client-Ip $remote_addr;
        proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header  Host $host;
        proxy_pass  http://unix:/home/my_app_folder/web-app/tmp/sockets/unicorn.sock;
    }
}

I have a problem. Everything works fine, I can go to http: // my_ip: 3000 , but the Rails URL helpers (like root_url, ect.) Don't have ports ( http: // my_ip ).

, URL ? Nginx , , Unicorn? , Webrick, URL http://localhost:3000 URL- * _url 3000. .

.

+3
1

- :

default_url_options[:port] = 3000 if Rails.env.production?

, Rails, :

Rails.application.routes.default_url_options[:port]= 3000 if Rails.env.production?

- :

default_url_options rails 3

+5

All Articles