Jump to content

Newbie Webpage Access Question


Rayj
 Share

Recommended Posts

I'm fairly new to programming so bear with me.

I have a webpage that is access like this:  https://xxxx.com:1234  I am using node.js and not apache.

What is the best way to change the access to https://xxx.com

Next,  the page has a drop down menu.  It has 3 choices:  Super User, Moderator and User.  I want to access the page something like this:  https://xxxx.com/SuperUser  or https://xxxx.com/moderator or https://xxxx.com/user

The 3 choices have to password protected also.

The code looks something  like this:

<select>
                <option>Super User</option>
                <option>Moderator</option>
                <option>User</option>
</select>

 <button>Continue</button>
...
...
...
var select = document.querySelector('select');
var button = document.querySelector('button');
...
...
button.onclick = function() {
var access = select.value;

 

So I have to get rid of the button.onclick for one, but how do I incorporate the same access into a URL?

Thanks in advance!

Ray

 

Link to comment
Share on other sites

The first part of your post mentions server routing, you then go on about some client-side JS, the two are (pretty much) unrelated.

On 26/08/2017 at 11:36 PM, Rayj said:

I have a webpage that is access like this:  https://xxxx.com:1234  I am using node.js and not apache.

xxxx.com is a domain, it must be pointed at an ip.

The :1234 declares a port.

The server you set up will have an ip, traffic comes in (usually) on port 80 (http) or port 433 (https) by default. Many other ports can be exposed and you can configure other defaults if you wanted to.

Sounds like you have a node process connected to port 1234. Get the ip of your server, point the domain to that ip and hit it with the browser (or other) and it'll route to your ip port 80. Either attach your node process to port 80 or create other routing rules to route general port 80 traffic through to port 1234 (where your node process is running), there are many many ways to do this. A common way is to setup an nginx or varnish reverse proxy on port 80 to route traffic from xxx.com to port 1234 (apache can also do this fairly easier). There are many reasons why a reverse proxy (preferably a caching one) are useful to set up in front of your services (such as the node process).

On 26/08/2017 at 11:36 PM, Rayj said:

I want to access the page something like this:  https://xxxx.com/SuperUser  or https://xxxx.com/moderator or https://xxxx.com/user

After xxx.com is routing through to your node process you're in the realm of declaring what happens based on the url.

Node has a core http module for setting up a basic process that will listen for requests on a specified port, lets assume you're doing that (libraries such as express, hapi or koa build on top of this and in practise you'd probably want to use a higher-level abstraction).

For example, hitting xxxx.com in the browser will send a GET request to your node process with a route of '/', there are many things in a request but for now you just want to do something based on that route. So you inspect the request object, see that the route is `SuperUser` and do whatever you want based on that route.

On 26/08/2017 at 11:36 PM, Rayj said:

The 3 choices have to password protected also.

There are many libraries that can provide various sorts of authentication to your application, most can attach to a higher-level library (such as express, hapi, koa etc) and there are many many examples out there, although it isn't particularly trivial to add these in usually.

You can also set up your proxy (nginx, varnish, apache etc) to handle basic authentication (and possibly more complex rules also).

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...