How to ssh port forward into a server to access a mysql host server for local work on Django web app and Jupyter notebook? - amazon-web-services

I'm unfamiliar with this terrain, so if any one can guide me in a step by step manner- it would really help. My MySQL database sits on a AWS host X- "ec2-xxx-xxx-xxx-xx.compute-1.amazonaws.com". It is blocked to access from individual local machines and is usually accessed from another working server Y- "ec2-yy-yyy-yyy-yy.compute-1.amazonaws.com" through port '3306'. Now it is especially inconvenient to access this via terminal SSH every time and scripts while they run, its hard to prototype or build an elaborate app. I'd like to set up a SSH tunnel from my local to server Y to be able to access MySQL host X from my local machine, to run queries from my locally deployed Jupyter notebook as well as local working-in-progress Django web app.
The reason why I ask for something more step-by-step is that I have to port forward to another server hosting a redis database which again is accessible through a specific server only. So, I'll be able to carry the solution from here to there too. I'm willing to go into chat as well if needed, but I need to resolve this rather quickly. Thanks!
PS: I've tried many guides off of the internet, but nothing has worked, it's become clear to me that I'm missing some foundational understanding or pathway. That's why I'm here, trying to start from the ground.

Related

Installer for local webapp for stock management using django

I am looking to build a webapp for stock management, since it does not need to be hosted on the internet( only admin and sellers can access it ), with it's database on the local computer, I need to find a way for making it easier for the sellers to use the webapp without running a server and all that stuff since they are not tech-savvy
A server is not mainly a computer on the internet or cloud. You can use a local computer as a server. This tutorial is a great way to gather all of the Django application's parts into a single docker-compose file. You can run this docker-compose on any computer, and every computer inside your local network would have access to it (obviously, you should put the computer running the docker-compose in your local network first). Make sure the server's firewall (The computer running the docker-compose) allows traffic on the application's port.

Port mapping in Windows Server 2016 - Docker

I have been trying to setup Docker in Windows Server 2016 in an AWS instance to run an IIS program.
From this question,
Cannot access an IIS container from browser - Docker, IIS has been setup inside a container and it is accessible from the host without port mapping.
However, if I want to allow other users from the Internet/Intranet to access the website, after Google-ing it, I guess we do need port mapping...
The error I have encountered in port mapping is given in the above question so... I guess using nat is not the correct option. Therefore, my team and I tried to create another network (custom/bridge) following instructions from
https://docs.docker.com/v17.09/engine/userguide/networking/#user-defined-networks
However, we cannot create a network as follows:
; Googled answer:
https://github.com/docker/for-win/issues/1960
My team guessed maybe its because AWS blocked that option, if anyone can confirm me, please do.
Another thing that I notice is: when we create an ECS instance in AWS,
So... only default = NAT network mode is accepted in Windows server?
Our objective: put the container hosted IIS application to Internet/Intranet in Windows Server 2016...
If anyone has any suggestion/advice, please tell me, many thanks.

Installing Wamp on a Network Drive

Ok, I have a quick question to ask all the veteran Wamp users on this board.
At work, we are currently working on a web application. We are trying to use Wamp to design everything, but we have a problem. All the computers right now have wamp installed to the default location (C:/wamp).
Our problem is, we all want to have access to the same MySQL database so we can edit it at the same time. Right now, only one person can edit it at a time to prevent losing the work of someone else.
When done, we just dump the mySQL folder onto a network drive so whoever wants to edit it next can take it and use it.
This isn't very time efficient, so we're wondering if its possible to install Wamp directly to a network drive in some way. We tried doing it just now but we can't get Wamp to start services.
So any type of advice will be helpful
i think these two thing would help you :
1: install wamp in only one system then in apache configuration file listen to his lan ip in order to others can access it in this way you have just one database server
2: as you've installed wamp to all systems choose one system's database as main and in mysql configuration define a new server wich server's ip is that system's lan ip
then users instead of using localhost for connecting to mysql will use that ip

How do I access my Django server from outside?

My computer is connected to our college's local network. I am able to access my django server in the same network from another computer. When I try to do the same from an outside internet connection, I get an " Webpage not found error" . I used the ip given by Whatsmyip.com to access it from outside. Also, I started the server using the command : python manage.py runserver 0:8000
Use something like:
LocalTunnel http://localtunnel.me/
Ngrok https://ngrok.com/
These create a tunnel to your localhost. You cannot host from a common IP shared by an internal network. Read more about localhost here: http://en.wikipedia.org/wiki/Localhost
Please note that the tools above allow you to share a link to your site and is mostly meant for development and testing. If you really want to host a Django server, either do it on an external server or contact your infrastructure team in college to see if they even allow such a thing.
For external hosting, Heroku (https://www.heroku.com) can be a good option with a reasonable free plan.
This depends on your college network. Often, computers in local networkds are behind a NAT (one single external ip for several clients). At this point, the request cannot be routed from out- to inside. Maybe a college technician can help you to route your page.
I think it's first important to note that manage.py runserver is for local development. It is not meant to be used for deployment.
If you want to access your website from "outside", you should consider deploying it. You can then read more about this here : https://docs.djangoproject.com/en/1.6/howto/deployment/wsgi/
Also, like stated in other answers, depending on how is configured your college network, it may not be possible to access your development server from outside, because :
It probably has NAT rules for local networks
There are probably port restrictions and a firewall for outside access (usually college networks are very restrictive from inside AND from outside)

Custom django runserver command which establish ssh tunel before running server

My application use database which is on another server. To increase security, access to db server was restricted only for specified production servers.
However sometimes I need to have access to this db, when running development environment from my localhost.
For now a simply run in another console before running server:
ssh tunnel#server-with-access-to-db.com -L 12345:localhost:3306
..which works great, however I need to remember to do that.
I am wondering how to write custom runserver which will establish tunnel automatically, and what is important, will close that tunnel after server will be shut down.
I know that in the future VPN will be much better, however it is not possible for now.
I will be grateful for any suggestions.
FYI: one part of writing custom runserver command is extending it. You can use this example to do so.