简体   繁体   English

如何使用Nginx将我的域连接到我的节点应用程序

[英]How to connect my domain to my node app with nginx

I bought ubuntu server in digitalocean. 我在Digitalocean购买了ubuntu服务器。

I am connecting my server IP through ssh on my terminal and i create a small node app and after starting the app, I can able to see my app running on my http://myipaddress:nodeport 我通过终端上的ssh连接服务器IP,并创建了一个小型节点应用程序,启动该应用程序后,我可以看到我的应用程序在我的http:// myipaddress:nodeport上运行

How i can i connect my domain to this? 我如何将我的域与此连接?

I bought free domain from freenom for testing purpose. 我从freenom购买了免费域以进行测试。

By following some tutorials i make a /etc/nginx/sites-available folder into my server and create a file called default and write code like this 通过遵循一些教程,我将一个/ etc / nginx / sites-available文件夹放入我的服务器,并创建一个名为default的文件并编写如下代码

server {
    listen 80;
    server_name sameer.tk; // i bought this domain from freenom
    location / {
        proxy_pass http://my_private_ip:3004 //with nodeport
        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;
     }
}

But if i hit sameer.tk after the setup its not working, i even restart my nginx. 但是,如果在安装程序不起作用后我击中了sameer.tk,我什至会重启我的Nginx。

You no need any nginx for node server. 您不需要任何nginx作为节点服务器。 You may run node server as 80 port and open 80 port in network security group. 您可以将节点服务器作为80端口运行,并在网络安全组中打开80端口。 After that, you should point domain to your instance public ip address in your domain management panel. 之后,您应该在域管理面板中将域指向实例的公共IP地址。

Ref: 参考:

https://www.digitalocean.com/community/tutorials/how-to-point-to-digitalocean-nameservers-from-common-domain-registrars https://www.digitalocean.com/community/tutorials/how-to-point-to-digitalocean-nameservers-from-common-domain-registrars

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

相关问题 如何将我的网站连接到我的节点应用程序? - How to connect my website to my node app? 如何使用Nginx将节点应用程序连接到节点api - How to connect node app to node api with Nginx 我的网站如何知道连接到我的 Node 应用程序? - How does my website know to connect with my Node app? 如何将我的 node.js 应用指向一个不存在的域 - How to point my node.js app to a non existing domain 如何将离子应用程序连接到cpanel节点服务器? - How can I connect my ionic app to cpanel node server? 我已经通过云9创建了一个节点应用程序,但是如何将应用程序与网站连接起来? - I've created a node app through cloud 9, but how do I connect my app with my website? 如何将在 android 设备中运行的 Ionic 应用程序连接到我的电脑(本地主机)中的节点服务器? - How can I connect my Ionic app running in my android device to my node server in my pc (localhost)? 如何连接我的移动应用程序(用 lua 编写)和我的服务器(用 node.js 编写)? - How to connect my mobile app (written in lua) and my server (written in node.js)? 如何将我的本地 node.js 应用程序连接到我的 Heroku Postgres 数据库? - How can I connect my local node.js app to my Heroku Postgres database? 如何将节点应用程序连接到Azure SQL数据库? - How can I connect my node app to my azure sql database?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM