How do I write my NodeJS server to an existing domain? - node.js

Okay so I'm in like a really weird spot.
I need to set up a nodejs server for a messaging app, and I want to put the server on a url I already have. I have full access my directory on that site (ex. I can access sitename.com/~mypage/) and do things with it through filezilla, but I cannot access the hardware or the base domain (ex. I can't touch sitename.com but I can access ~mypage).
how would I set up the server on there? Do I need to initialize it on my own computer then upload it or do I install nodejs on the server and initialize it there? or can I use a local host for the app? Thanks.

if you already have a site running you won't be able to just slot a node app into ~mypage by adding it through filezilla.
The best way to do this in my opinion is by setting up through your domain management that ~mypage points to where you have deployed your node app (ie heroku, AWS), but if you have access to do that you may as well set up a subdomain to route to the app (ie app.sitename.com)
However, if you really cant access the domain settings, my suggestion would be to deploy your node app on Heroku, AWS or GCP then either:
A) set up a a ~mypage that redirects you to your app url if someone visits it
OR
B) set up a page with masked forwarding like so (so the browser url stays as sitename.com/~mypage/):
<html>
<head>
<title>Page Title</title>
<META name="description" content="Page Description"><META name="keywords" content="keywords, for, page">
</head>
<frameset rows="100%,*" border="0">
<frame src="http://linktoyourapp.herokuapp.com" frameborder="0" />
<frame frameborder="0" noresize />
</frameset>
</html>

Related

IIS bindings and google analytics

I have a question that relates to setting up google analytics on a website. I have one website setup on a Microsoft server using IIS. Let's call it www.example.com
for this website I have added a couple of binds that relate to the different domains like www.example.eu and www.example.gov
With this is mind I only have one website to manage and to control and all the bindings exist just to have the possibility of using all the domains purchase without having any redirects when an user try to reach the website.
It's now time to start the analytics. But I'm getting a bit confused on how I'm going to setup this.
I'm I corerect and thinking that the only thing I need to add to my website is the following code?
<!-- Google Analytics -->
<script>
window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;
ga('create', 'UA-XXXXX-Y', 'auto');
ga('send', 'pageview');
</script>
<script async src='https://www.google-analytics.com/analytics.js'></script>
<!-- End Google Analytics -->
Or do I need to think of a cross domain setup like?
<!-- Google Analytics -->
<script>
window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;
ga('create', 'UA-XXXXXXX-Y', 'auto', {'allowLinker': true});
ga('require', 'linker');
ga('linker:autoLink', ['www.example.eu, 'www.example.gov'] );
<script async src='https://www.google-analytics.com/analytics.js'></script>
<!-- End Google Analytics -->
Again www.example.eu and www.example.gov is not a website but just a bind to one www.example.com.
Hope you can help me to figure it out the best way to setup google analytics.
Thank you in advance.
Google Analytics is a client-side technology, so it does not really "know" about your server settings and simply looks what is in the address bar of the browser.
If your users can browser the different domain names, and you expect them to change between domains during a session then you need the cross-domain setup with the linker.
If your users can access your website via different domains, but you do not expect them to change from on domain to the other during the visit then you do not need the cross-domain setup.
(For completeness sake, if you had redirects your would not need cross domain tracking either as long as the redirect is done via the server, or done client-side before the tracking code is executed).

IIS paths ignoring application folder

I lack the know-how with IIS and IIS manager to even have the proper google terms here, so I hope you'll keep that in mind if you're tempted to click that downvote button.
Thanks.
Okay, so I have an angular application that I just moved over to an an IIS server after developing it locally, without using IIS.
The IIS-based copy of the application works, in that it will serve index.html as expected. Unfortunately, links to external files (.ccs, .js, etc) are all broken.
The application lives in this folder:
\\iis.dev.local\c$\inetpub\wwwroot\the-application
And it's .css file lives here:
\\iis.dev.local\c$\inetpub\wwwroot\the-application\css\main.css
As originally written, the link to that .css file, which we'll call "link 1":
<link rel="stylesheet" href="/css/main.css">
Which worked fine in development, but doesn't work on IIS.
However, this does work, which we'll call "link 2":
<link rel="stylesheet" href="/the-application/css/main.css">
See how I had to add the folder that the application itself sits in? Which is strange, because relative to index.html, "link 1" should be correct--but it isn't.
How can I convince my application that its base url should be the folder it's sitting in, and not one level above?
Random partial guesses and/or useful information?
1) The application sits in the default application pool.
2) Something, something web.config?
EDIT: screwed up some paths.
Try using the <base> HTML Element to set the root.
https://www.tutorialspoint.com/html/html_base_tag.htm
In your example it would be:
<base href="https://www.the-application.com" />
Then the rest should flow, with relative paths.
When developing on your local machine you are most likely running under a Virtual Folder under the DEFAULT website.
When you move to a server you are now running at the ROOT of the site.
Options:
Create a new site on your DEV Machine at the Root of IIS. Then use this path to test your site. When you migrate to production the paths will be the same.
Create a variable with the correct path, and if running LOCALHOST (in the url) use one path, else the other. Use JavaScript to add the link to your HTML (Something I have done with a JavaScript site under IIS for Cordova Development).
Change your page extension from .html to .aspx (yeah I know who wants to do that...) then change your links as follows. (I had to remove the starting < and ending /> in the code below, it would not format in the post)
link rel="Stylesheet" type="text/css" href="<%= ResolveUrl("~/css/main.css") %>"
When you browse your source afterward you will see... (or when you navigate to sub-pages it will put the correct relative path in place for you)
<link rel="Stylesheet" type="text/css" href="css/main.css"/>

Have a domain bring up a page hosted on another domain

I need a domain--without hosting--to bring up content from another server. I.e. I have access to the domain's DNS, but nothing else.
How do I make a page--hosted on my server--load when my clients' URL shows up?
To clarify, I want a visitor:
To type sl.wellnessandyourself.com
For the page www.ceramiclion.com/drops/index.html to show up
For sl.wellnessandyourself.com to still be the url in the user's browser.
I've heard mixed comments on this. Websites like Weebly are able to do this. How can I do this as well?
EDITED:
See the above comment about CNAME as a far better solution than what I just offered.
I am not fully certain, but I think the only way to really do this is to use an IFRAME tag embedded in your own page code:
<html>
<head>
<title>IFRAME Example</title>
</head>
<body>
<iframe style="min-width: 100%; min-height: 100%; outline: none;" src="http://www.ceramiclion.com/drops/index.html" />
</body>
</html>
This sort of hearkens back to the good ole days of frames in HTML. Ahh, memories.
Why not use a CNAME? This is pretty much what it's used for. All you need is to edit the DNS records for the domain name. Obviously, you have to have access to these, but, it's pretty simple to do. No hosting required on your end.
You'll set up the CNAME for sl.wellnessandyourself.com to be www.ceramiclion.com/drops, and it should work how you want it.
Here is more information:
https://serverfault.com/questions/65712/using-cname-to-point-to-another-domain-to-save-ip-addresses
https://support.dnsimple.com/articles/cname-record/

How to pass windows authentication credentials to different site on the same server

I have an asp.net mvc web application on IIS server(MySERVER). On one of the pages I use a IFrame element to display another resource(QlikView Dashboard) which is also servered up from the same IIS server(MySERVER). The IFrame element that I use on the first site is as follows.
<div id="reportFrameDev">
<iframe id="reportFrame" src="http://MySERVER/QvAJAXZfc/opendoc.htm?document=Ashwini/CMS.qvw&host=QVS#bh-vmapp01" frameborder="0" height="800" , width="100%"> </iframe>
</div>
The first site has Forms Auth. But this second site (MySERVER/QvAJAXZfc/) is configured for windows authentication (which I dont want to change) and this bothers users with a windows authentication pop-up windows. I want to avoid this pop-up without altering the windows Authentication mechanism(on the second site). So I am exploring different ways to pass on windows credentials from my first site to send one(both on the same server - MySERVER) securly. The best I guess would be on the server side code itself. If not what are the ways using cookies, What about local storage? From the browser can this be done Securely?

htaccess problem

i have to write htaccess for mysite. actually we have two domains. '.com and .in' . for example i opened '.com' site it will actomatically access files from '.in' domain. there is no files in .com site. how to write .htaccess for this.
thanks.
If you have access to the web server, use the configuration to archieve this. In case of apache2, it would just require a server alias in the virtual host. Otherwise, use redirects or url rewriting.
If you cannot use them either (because you are on a limited virtual environment, f.e.), place an index.html in your .com directory, configure it to redirect via meta-refresh tag. Place the following line in the header section of your index.html:
<meta http-equiv="refresh" content="0; URL=http://yourinsite.in/">
Then use the DirectoryIndex directive on a .htaccess file to automatically load it as default index page:
DirectoryIndex index.html
This brings up the index.html when the user browses yoursite.com/ and lead her to yourinsite.in automatically.
Do you have access to the server config? Judging by your comment above what you actually want is to setup a server alias, where the .com and .in sites are the same? This will make the .com site load the .in or vice versa.
Another solution you could use if you don't have server access it use a domain frame cloak, which will keep the .com URL in the address bar but load the .in site inside a frame, put this code in index.html on the .com site, fill in what toy need to.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
<html>
<head>
<title>TITLE OF THE SITE</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<meta name="Description" content="Description of the site"
</head>
<frameset rows="100%,*">
<frame frameborder="0" src="http://domain.in" scrolling="auto">
<noframes>
<body>
<p><b>Welcome on our site. Your browser do not support frames.</b></p>
<p>Click here to go to the page.</p>
</body>
</noframes>
</frameset>
</html>

Resources