R
R
Risent Veber2016-04-15 09:07:19
Nginx
Risent Veber, 2016-04-15 09:07:19

How to replace localhost:3000 with dev when starting rails server?

How to configure nginx and what to write in /etc/hosts to type dev instead of localhost:3000 in the browser line every time you start rails server?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mikhail Osher, 2016-04-15
@risentveber

1) Use dns-masq
2) Install nginx to proxy requests. Something like this.

server {
    listen 80;

    root /path/to/project/public;
    index index.html;

    server_name project.dev;

    location / {
        try_files $uri $uri/ @app;
    }

    location @app {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_redirect off;
        proxy_pass http://localhost:3000;
    }

    location ~ /\. {
        access_log off;
        deny all;
    }

    error_log  /var/log/nginx/project-error.log error;
    access_log /var/log/nginx/project-access.log;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question