How to Setup a new Domain Name in NGINX - Golang Web Development

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] hello guys welcome back to the channel this is tutorial series number five here in marlin against code regarding this uh golang web development series and now we need to install or set up this new domain which we recently purchased these uh [Music] mahalikanscode.com and then we would like to put this and then configure this in nginx web server there then so that we can replace that ip address that currently is uh displaying from our engine x we don't we don't like uh we don't like we don't want this uh ip address to be there it's not the correct way of course guys uh okay so we need to uh see this in action this maharikansko.com and now we will walk through with you guys on this uh nginx configuration regarding it is a fresh uh nginx uh it's freshly installed from based on the latest ubuntu server here which is the 20.04 lts which is a long term service okay guys let's dive into this tutorial okay guys welcome back to the channel okay this is uh the default um engine x uh all configuration files are here guys this is from uh freshly installed from our previous uh discussion here in harlequin's code i log on to my ftp server here i'm in a ftp connection using this filezilla another godzilla guys okay so this is the filezilla which is a very uh popular ftp program for our uh connectivity through uh this uh ftm ftp uh connection guys but this one is a secured guy so we always connect with the port 22. you can take a look on my previous video if you just jump into this video guys so on how to um how to set up this uh ftp server from our ubuntu 20.04 and then we can connect from this client version of this ftp which is the filezilla then right now we can freely connect now i connected as a root directory guys because right now we need a special privilege or highest highest privilege because we need to modify the nginx configuration files right now we need to create a new domain a new server block and then we can public publicly launch this some harleques code and then we host it in our web server okay so right now i downloaded this to cachar.time i downloaded the entire nginx under this atc directory and then nginx under the atc is a lot here guys so you can explore more also a lot of softwares if you install or all this the os kind of thing uh os related all these things guys so i just download these and then download all and then download it to my local versions here uh i'd like to do this guys because i don't want the uh what they call this i'm using this nano i mean you connect uh your website right here for example this is your console and then now you would like to uh what they call this clear first these are all my testing my previous one so i would i don't like to write everything here in the console because not so friendly guys of course but exactly it's up to you if you prefer here then you can do the nano here i edit the thing create a file it's up to you but uh for me i always download from our web server using this filezilla and download all this thing but you must be very careful guys because this one is a very sensitive information no unwanted person should know about this nginx and these are all the your configurations are here so you just be very careful only okay okay guys there is a default thing here which is the default uh configuration for our engine x when we installed this right now i have this copy download downloaded on my development [Music] laptop here so right now it's under we need to focus under these sites available there is a default file there i mean this is a default configuration file the c c and f something okay so this one i open guess under these sites available not under the sites enabled later we will be enabling all of the domain must be enabled okay so later there is a command for that then we can enable the newly installed domain name there okay so these are all the uh default configurations all these uh settings all um nicely in place here by the internet itself so you can fully read all these uh necessary and information for this nginx web server okay so the default here there is a server block this is what they call the server block guys this one is obviously it's been disabled or just like a note okay this one all disabled if you see that there is a sharpie just a quick overview on it guys but this one is a by default it's open uh the port anywhere in the in the world network and any of the web server or any kind of a web server is either iis or any kind of a server there guys so we always open the port this one is a http port this is the standard port for accessing any site guys so this one is a port 80s by default all are open and then the 443 is of course is the for the ssl there is a nodes here and these are all the uh secured http so this is the port for the secured um what i call this um https guys okay so by default also there is a root here there is a root bar www this is in the default directory for the engine x guys so particularly tied up with this ubuntu okay so we need to quick check on this if this uh directory is exists or not in your web on your uh web server so we need to take a look and then we need to navigate i'll try the var and then drop down there then www and then the html there so the default page is this debian here so we can freely create a new directory here you must be very careful about this directory here guys if you don't know yet because even it's a publicly accessible files either in your javascript html css these are all the files that you need to place here not the source code of your okay guys and not the source code okay it should not source good so only those uh public html any no sensitive information must not be here okay guys so this is just a quick uh overview only and then a quick uh security things okay guys so must be very couple no source code here should not be here everything should be under your either your route or your home or directory i have another account here this is the higher highest account privilege which is the root okay so these are all the roots here i don't i can create my folder also here in our golang web development we can create directly from here and then all our static pages will be thrown here later we will create uh this uh what i call this mahalikanscode.com then you will place all the html here later we will do that guys so okay so here is the thing is uh this is the root for uh all the public html there or whatever i guess okay so there is a server name also there is also um by default they set null here but it's okay these are all the default one if you have any other ip address or something normally we will put here in the default test looks like you have a fullback uh you can put this ip address here uh your public ip address then you can uh place it there so we can uh instead of like a underscore you can also put your ip address you can on this one also it's possible here so these are all the thing guys and then the location these are all the default here normally we don't touch much here these are all the common what they call these configurations here these are all for the php kind of thing this is a fast cgi server this one you can also enable it's by default it's disabled here uh it depends on your current php version or your the socket there if you have this uh normally we will uh enable these guys particularly because we need this mysql database normally we have this mysql or php my admin we are all using the php scripting there so we can enable this okay so this one by default is disabled so right now we don't use yet but maybe when we install uh let's see what will happen guys okay so by default there's a deny here for all these uh hd access we can enable these guys no worries but in ideally we are not setting up everything in the default here we will create another particular domain here under this site's available uh folder okay so we don't touch much here because this one all it will be all affected unless it's very common for you or you don't want to set everything here or this one is all global settings guys for the uh what they call this nginx but this one you can skip for a while all these settings as well so right now we will create a new domain okay we can create directly here or we can also create a new command for we can also create a new command uh create the new command create a new domain by using the command sorry guys sometimes we we just uh human human being okay uh okay i have some small notes oh okay okay uh normally if you uh want to generate the common or the so do command guys for this uh when you create a new file for our domain like any domain any kind of a domain this is the default syntax guys so do cp ctcs it atc engine x and size available then default all these things here we need to create for this so just this is the default command guys so right now when we go over here it's up to you when you i already pasted here guys so some text may be cut because it's not in the console it's not automatically wrapping up the text so we just press enter guys so it's normally it's no message then we just go back here and the sites available okay we will just refresh okay so the file is here guys so newly created the uh file for our thing is we can just download this this is another way and then uh i normally go there and open so the harlequins code is here so normally all the pre-tags all the documentations are in place and then they also enable this everything here guys so right now this is the raw file created by that command uh using the sudo thing kind of thing there okay so again there is a bar html we all need to set up everything here so okay to capture our time guys so i will be doing quickly okay guys uh to catch our time i created this uh uh recommended guys you need to put all this uh thing and just retain all this information here for our documentation for the nginx there so i added this one guys in you know i think i also put all this rate limiting here in our nginx so this might help our uh what they call these uh ddos kind of uh attacks guys so also the engine x also handling this uh by its nature handling these adidas attacks guys by the way if you remember that we uh we have configured our network traffic using this cloudflare uh then that one from there itself there is adidas attack protection from our side here also when the uh bridge to the cloud player there if the road falls there then normally it will be blocked there no no worries about that but again we need to um check this uh what they call these uh the nginx engine x itself they also have this kind of adidas attack guys so uh i added this as a rate limiting to like a 20 burst as recommended on this uh documentation from the what they call this nginx site itself so you can the entire nginx configuration guys is is a lot there so we can always read from there for more uh information but this one is a very decent enough and for our configuration to run our domain with the decent kind of uh what they call this protection from our thing but right now we don't set up first our https which is the secured what they call this we need to install that cert boot first then prior we can use that uh right now we need to uh i just want to illustrate to you first that uh we need to we can deploy using this uh minimal configuration without the https but uh but it's recommended guys that we need to set up the https using this cert boot so no worries about that we will continue after this so in our next video guys so stay tuned for that okay so i created this and then i remove few of the common nodes there it's too many also okay so i just added these this one is a default one guys so in the previous version they don't have this deviant kind of html there so in in the previous version of nginx but right now uh they are adding this deviant just leave it diverse first guys so okay then uh the server name i will uh normally we will set up it like this uh elegance.com or www with the with the www there if someone type the www then they can also serve from this nginx or without the or the bare domain name okay so normally we just put these things here guys so also we would like to change that root directory normally it's uh the default one is it's just up to here so now we have some specific uh root directory here for this domain mahalikans.com each domain guys you need to set up like this this kind of thing for this uh as you can as you can see that our site is available there is a default and then the marlinkans code this is our created newly created domain here so we need to configure this domain okay so but the root the default here is always like this a bar wwe then html this one leave it there okay so here is a more specific kind of thing so we need to set up like these guys okay so uh then i created this uh make sure that you created this uh directory as well uh by using this of course our favorite sftp here which is the filezilla i created this directory under this um ww html and then i created this new folder here which is the normally you will create paired it with this is the best way guys to organize your static files or publicly accessible files over the internet so all your javascript css will be in place in this domain these are all the uh properties of this amahilicans.com domain or site so when you go in there there is a public also public html but this is the recommended uh path guys okay so okay then the public html static all your assets here you can create a new uh like uh like assets or your these are all your javascript or js here you can create a new js folder or you can create a new css file it's something like that guys all your assets are here also you can create another like um many kind of things like a library or or javascript library or any kind of uh library there so so many kinds of js components you can organize under this static guys you are bound only in this static static folder here later because you know i uh later you know in our golan web development we will be placing all the uh what they call this public html here the css or anything like a bootstrap or like that so if you download it or you can use the what they call this the url there it just we don't we don't download but uh i normally i download all the files guys because anything might happen or something like that but because we don't worry about the the distribution of this like the cdn or something they always have this cdn but uh for me i would like to download it since uh we have this cloud player the cloud flare is a very good cdn for us already all the static files javascript all minified automatically for us so when they serve over the browser there then it's totally okay is all our javascript is minified auto minified when you tick that from the configuration if you miss out the video guys you can always take a look on my previous video okay so these are all the ideal um structure guys for our static files for each domain if you have a multiple domain hosted on this uh engine x that is a normal one guys um you can host multiple domains there then you can just simply create another uh directory here like your another domain like a new domain.com or something like that i guess then you can follow along uh all these uh structure here so right now we only have one hosted domain in our engine x so normally we we will have this one okay so all the static here okay we'll come back again then uh this one we don't enable yet uh next time we can enable back um okay so we will uh well once we install our uh what we call this uh php my admin guys wins so stay tuned for that we need to install photos uh software because we need those mysql to to be installed in our web server as well so that we can uh host a few uh of course our database guys or you can install mongodb here also because we we already have this console here this is our web server so we can install anything here as long as you have the root uh privilege or access so we can install anything that we want guys this is what i like for daily note because the you can also you can you have the freedom to install whatever you want guys for your at least five and this is a very cheap uh um domain i mean this uh hosting then you can you can have all this console privilege here so you can just manage your own server guys for other hosting there is also a cpanel or something but uh i prefer this way because you can fully freely install whatever you want there okay so we need to uh this one also i need to speed up a bit this one issue our static guys so this alias is the command for the nginx so this is uh what they call this uh when we access our harlequins.com your domain slash natick static so so all our javascript css all these things will be or our html will be doubling will be all stored under this static here this uh directory but again it's up to you guys but but the recommendation is i always recommend using this uh this this kind of uh directory in this path okay so uh also i added this additional thing we can we can cache all these jpeg all these images ico css javascript pdf ttf dtc all these standard guys you can always add more here then you can add a automatic header which is the access control allow origin all these things and expire in seven days for those browsers that after they serve these kind of files that we have in our pages or html pages then automatically the nginx will set the header for that for to expire for seven days but they also have here but our cloud flare is the cloud player also doing this caching guys for us so that one is a very helpful for us and then it will speed up our even though we have a very minimal resources in our web server but uh what they call this uh cloud player is very good for caching and then all these i mean they serve because they have a lot of network as well and very fast to download so let's head back for us guys as a developer so again this one another one is that we enable this uh location here which is the access log all this i just added this guys the default here is uh this one is this deny all actually is the same but you can also add uh access log to turn off and then deny all as well so these are all the hidden files like this hd access okay or any apache document route so okay guys we'll upload this file to the sites available okay so we will uh you always do that yes and when you change we're guessing the files will be modified and then it will be refreshed automatically again we'll just upload guys and just replace over this existing file always take this always use this action so that it will not ask again guys uh now we need to go to our server here okay so we need to use this um uh sudo nginx reload these are all when you reload guys but right now we need to enable the the domain versus right now we don't have these uh the sites enabled so although you uploaded this file the marlikens.com is there right you guys so but the site's enabled is not yet so we need to enable by using the command like by using this command guys so i highlight this command so i just pasted here so that you will know this command so normally we will do sudo and then disable the standard command guys for the ubuntu then the atc engine x and sites available and then our new domain name you just replace with your own domain name here and then uh space here there is a space and then after that the atc sites enabled it will be thrown another file there it's like link something guys so it will be enabled so i will just paste this uh code because i replaced it with the market scout here so i now want to enable this marlikan's code go back to your console again as long you have the uh root privilege and then press enter uh normally it will just uh keep quiet guys nowhere just kidding okay so and then until we refresh guys so we will have this um hold on okay so until this uh we need to refresh guys so do engine access reload see there is an error or not from our configuration okay a duplicate server okay there is a duplicate there so this is the the kind of the error guys so we need to take a look on this okay guys uh i already uh changed all these things for the meantime i remove all the caching first guys because we need to install all the necessary what they call this um fast cgi or something the apache we can concurrently uh do that in the separate uh discussion guys so we will do that in the meantime then we can enable this that one is totally when we use those caching things uh incorporate with uh this uh cgi all these uh settings as well so we will do we will do that in our separate discussion guys uh right now i disable all this caching first okay so and then upload it back to our server here which is the maharikans code and then uh all these sites available and then i also also enable all this mohawk code by using that code earlier i showed you on how we can disable or enable this uh uh maharikas code as you can see that there is a what we call this as some some link automatically created when we issue that command okay guys this command and what i'm talking guys uh this is this is the command when we enabled uh or enable the any domain domain name created in our uh engine x so right now these are molecules code then this is the command you just change with your own domain name there then you can execute in the console as long you have the root privilege okay so these are all the new settings guys and then when we sudo as reload then we don't have the issue any so all fixed with our uh this uh uh configuration for our engine x guys uh it will not it will not be reloaded with the with your this uh sodo engine access uh reload when there is an issue guys so right now we already fix all this issue so we just remove all those caching and then the server thing uh the only thing is uh we retain this lesson and listen 80 port 80 which is the default for for everybody for every configuration so because we have our default here indica so the default server is a port 480 um this i like this configuration guys you just retain from our default here and that's all then we will do all our future domains or new domains we will just configure with this uh lesson 80 but later when we go go along with our certification using this uh cert boot then we will enable all these necessary settings here for all the things uh for these things uh for the ssl uh okay so we will do that and then we already no problem and then uh again we need to uh change here guys our uh thing we need to uh at the moment we don't have the golem yet uh golang files we don't touch it yeah we just i just uploaded a very minimal index that html from this what they call this okay okay guys this one from the bootstrap there you can always go to the getbootstrap.com so there is a starter html there you can just copy all these things with the cdn there so for us it's just to test uh properly but in the future we will uh use this bootstrap css here for our web development example because it looks nicer guys and more robust okay so again we need to do some setting up because right now we're still seeing this because we need to point to our early node server there so and then we need to configure our uh like this our dns and then in hourly node guys uh we need to set up this new domain there so because i have two servers here okay so i need this domain to set up guys we need to go to this domain we need to add uh our harlequins here so i already added these mahlikans here for to create uh same video same server guys you need to go to your dns site so these are all my default for linux these are all the default configuration guys for the email also it's like that but later we will do our own uh settings so i will need i need to copy my ip address hold on guys i need to change my ip address for this because i have two servers here so i would like to change this uh ip address uh hold on for a while guys edit you can just simply edit this okay save and then for email this one later part level this one we don't need yet but i just changed this as well and then for ww we just change this with our specific ip address so these are all the settings guys so right now and then we need to go to our what i call this uh i have many domains here guys so i just go back here okay okay guys so we need to uh because right now and this one is still pointing to some of uh domain there for the godaddy so we need to remove view here uh this one is okay but uh this one is still in the godaddy there so we need to change this with the correct ipad this is a my ip address for this uh web server here in linux so i point to miley node not to go that deep since we we don't host our uh files there or hosting in a godaddy we just bought the domain name so i just uh replace it with this server ip here and then for our cloud player we need to point to this ip address okay so we need to save and then for our a record and then this one for the c name this one no need this one we can just delete yes um this one we can delete this we don't need this yet okay and then anything c name for wwe marlikan's code is okay and then the text record txt we don't have this yet uh the mail server we later we will set up and this one not so important at the moment because even if you have an um uh email here we can just set us a record again and then put the mail there something at the moment we need to point this domain itself first so okay if you have a sum uh the mx record mx record is for the thing okay for the mail for but later part we will have guys so uh right now is uh already changed to this ip address uh then we will try to refresh it let's see what happened okay very nice now no more good i need okay so totally it's working guys so i just tried the view source here so these are all the basic things for the hello world so we are copying this information so hello world so right now i uploaded this uh text file here from our this thing the hello world so let's see what will happen if i open the file hold on okay we will change a bit hello maharlikanz let's see guys so this is just a basic uh from the sample there guys okay once i try to upload load back again let's see what will happen okay it's totally working guys uh no worries this one is a very bare design guys so right now we have successfully changed our domain and then properly configured as well but right now this one is uh the the https this one still https guys but right now it's hosted on our cloud player here which is the flexible and that is flexible no not the full one because right now in our previous discussion we set this pool because the the what they call the server is still under the whole godaddy there so normally it it detects but when you click this uh change this option into full from flexible or something or full streak then it will throw an error because our what they call this web server here our nginx web server we don't have a necessary https yet remember that in our configuration here we don't have any enabled https so we cannot our origin server this is our origin server which is this uh root this early node but our origin server we don't have this uh this is the origin server guys uh from browser to cloudflare is uh is secured but uh when cloud players serve or get the files from our origin server which is our linux server uh currently we don't have the active ssl or tls encryption there so only this way is uh secured guys but uh going back to our server is not secured so we need to change this later on to full streak or full okay guys so when we have this kind of uh what you call when we enable this uh ssl here okay so uh right now we are totally working guys our hello harlequins here is already changed and then our domain is fully watercolor fully run using this configuration with this engine x here this configuration guys what i'm talking and then right now we can also enable this and then change here to our uh point back to our uh what i call this dns here we need to change this a record which is the marlicanscore.com then point to the server ip address there which is this ip address from our uh lead node so this is uh my server ip here so you can change a point that instead of whatever you're hosting there uh in my case it's a godaddy so i removed the type address uh earlier early on uh from our here so now instead of then go to the standard what they call the html here and now we can see our bare html totally uh take over guys from this uh from our lynode hosting server so thank you so much guys for watching my video here here in maharlikan's code see you in my next video guys we need to set up our assert booth there for https okay guys we have done all these settings and then um i hope you enjoy our tutorial series here in martin's code and um see you in my next video here in mulligan's code and then our next step will be to secure that americanscode.com site we need to install some necessary configuration and also this assert boot which is the free https for our domain instead of buying this expensive certificate then we can use this uh free and open source um assert boot https there so we will fully secure our web server our nginx web server and then and then we do some changes again for our cloudflare there and then stay tuned for that guys and then thank you so much for watching my video if you like this channel kindly subscribe to my channel so that you can have more videos like this and see you in my next video guys thank you so much for watching may god bless us all thank you and [Music]
Info
Channel: Maharlikans Code
Views: 285
Rating: undefined out of 5
Keywords: Maharlikans, programming guides, step by step guides, go, golang web development series 5, golang web development course, web development with go, golang tutorial, learn to create web applications using golang, building scalable web apps in golang, golang good for web development, how to set domain name in nginx, nginx multiple sites same domain, nginx multiple domains, nginx configuration, nginx multiple config files, nginx subdomain, how to host a website using nginx
Id: Er942noK27g
Channel Id: undefined
Length: 41min 44sec (2504 seconds)
Published: Tue Nov 10 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.