简体   繁体   中英

How to connect my domain to my node app with nginx

I bought ubuntu server in digitalocean.

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

How i can i connect my domain to this?

I bought free domain from freenom for testing purpose.

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

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.

You no need any nginx for node server. You may run node server as 80 port and open 80 port in network security group. After that, you should point domain to your instance public ip address in your domain management panel.

Ref:

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

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