简体   繁体   中英

How to config domain for Adonisjs project?

Simple when run npm run dev, adonisjs will run with domain:

http://localhost:3333

But i wanna config with domain:

http://blog.com http://blog.local

Please help me!!!

Your question is not clear but I'll try to answer.

  1. If you are trying to get those domain names on your development machine, take a look at this: http://adonisjs.com/recipes/4.0/dev-domains

  2. If you are trying to host your Adonis app on a server, take a look at this: https://www.digitalocean.com/community/tutorials/how-to-set-up-a-node-js-application-for-production-on-ubuntu-16-04

If you are in development environment or local machine there is an answer here

But if your are in production environment you should install and config BIND9 or something like that to work as DNS Server but there is an alternative and simple solution:

Firstly register on http://cloudflare.com and add your domain on your dashboard. then it gives your two DNS you should set to your domain. then in the cloudflare dashboard create a A Record to point your domain to your server IP

Then install Nginx on your server to work as a Reverse Proxy and use this config to point your domain to your awesome adonisjs project:

server {
    listen 80;
    server_name blog.com;
    location / {
        proxy_pass http://localhost:3333;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }
}

Enjoy!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM