简体   繁体   English

如何为Adonisjs项目配置域?

[英]How to config domain for Adonisjs project?

Simple when run npm run dev, adonisjs will run with domain: 当运行npm run dev时很简单,adonisjs将与域一起运行:

http://localhost:3333 http://本地主机:3333

But i wanna config with domain: 但我想配置域:

http://blog.com http://blog.local 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 如果要在开发计算机上获取这些域名,请查看以下内容: 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 如果您尝试将Adonis应用程序托管在服务器上,请查看以下内容: 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: 但是,如果您在生产环境中,则应安装并配置BIND9或类似的东西以用作DNS服务器,但是有另一种简单的解决方案:

Firstly register on http://cloudflare.com and add your domain on your dashboard. 首先在http://cloudflare.com上注册,然后将您的域添加到仪表板上。 then it gives your two DNS you should set to your domain. 然后会给您两个DNS,您应该将其设置为您的域。 then in the cloudflare dashboard create a A Record to point your domain to your server IP 然后在cloudflare仪表板中创建一个A记录,以将您的域指向服务器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: 然后在服务器上安装Nginx以用作反向代理,并使用此配置将您的域指向您的adonisjs项目:

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! 请享用!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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