1
votes

I'm trying to set up an SSH tunnel to access my server (currently an ubuntu 16.04 VM on Azure) to set up safe access to my django applications running on it.

I was able to imitate the production environment with Apache WSGI and it works pretty good but since I'm trying to develop the application I don't want to make it available to broader public right now - but to make it visible only for a bunch of people.

To the point: when I set up the ssh tunnel using putty on Windows 10 (8000 to localhost:8000) and I run http://localhost:8000/ I get the folowing error:

"Not Found HTTP Error 404. The requested resource is not found.".

How can I make it work? I run the server using manage.py runserver 0:8000. I found somewhere that the error may be due to the fact that the application does not have access to ssh files, but I don't know whether that's the point here (or how to change it).

Regards,

Dominik

1
Maybe django is expecting a Host: header other than Host: localhost? - evilSnobu

1 Answers

0
votes

After hours of trying I was able to solve the problem.

First of all, I made sure putty connects to the server and creates the desired tunnel. To do that I right-clicked on the putty window (title bar) and clicked event log. I checked the log and found the following error:

Local port 8000 forwarding to localhost:8000 failed: Network error: Permission denied

I was able to solve it by choosing other local port (9000 instead of 8000 in my instance).

Second of all, I edited the sshd_config file: sudo vi etc/ssh/sshd_config

and added these three lines:

 AllowAgentForwarding yes
 AllowTcpForwarding yes 
 GatewayPorts yes

I saved the file and restarted the ssh service:

 sudo service ssh stop
 sudo service ssh start

Now when I visit localhost:9000 everything works just fine.