zoukankan      html  css  js  c++  java
  • Making your local server accessible from anywhere

    In reality you probably don’t want to host you websites on your local computer unless you have a very good computer, a very good internet connection and you are an expert system administrator, but this is very useful to learn how the internet works.

    In this case I am doing this because I want to be able to develop on my computer no matter where I am. So I want to be able to SSH to my machine, modify my files and view my changes from a web browser. Here are the things that need to be done:

    • Setup a local HTTP server
    • Allow inbound traffic on port 80
    • Setup a free DNS service
    • Setup an SSH server
    • Forward requests to port 22 on your router to your computer

    Set up a local HTTP server

    I already wrote an article explaining how to do this: Creating local virtual hosts with Apache

    Allow inbound traffic on port 80

    To make your HTTP server available from the Internet you have to configure your router to send all incoming traffic on port 80 to your computer. The way to do this varies depending you router and ISP, but the steps are very similar most of the time:

    • Go to your router configuration page on a web browser. A lot of times it is http://192.168.1.254/ or http://192.168.1.1/
    • Go to firewall or DMZ setting
    • There will probably be a section that says something similar to: “Allow device application traffic to pass through firewal” Then:
      • Choose your computer
      • Forward external TCP traffic on port 80 (If you are asked for a range choose 80 to 80) to port 80
      • Save

    To test that everything went well you can search for “my ip” on Google and it will give you your public IP address. You can give this IP address to anyone and they will see you local server.

    Set up free DNS service

    Since most internet providers give their customers a dynamic IP address it is not efficient to access your computer that using that number, since it may change at any time. Luckily there are some free services that allow to overcome this issue.

    I found https://www.changeip.com/ did the job for me. You just have to click on “Free DNS” and they will let you choose a free subdomain. Then you just have to register and they will automatically detect your public IP. Now anyone can access your local server using that subdomain.

    Set up an SSH server

    An SSH server makes your computer available via a terminal to other computers using an SSH client. You can install an SSH server on Ubuntu with this command:

    1
    sudo apt-get install openssh-server

    Once the server is installed you can test it by trying to connect to it.

    1
    ssh yourname@127.0.0.1

    When prompted for a password enter your login password.

    Forward requests to port 22 on your router to your computer

    You can follow the same procedure you used for port 80, just change it port 22. Now you can ssh to your machine using the subdomain you choose for your server.

  • 相关阅读:
    My97DatePicker使用说明文档
    内存溢出之Tomcat内存配置
    myeclipse控制台不显示tomcat信息
    修改 MyEclipse 编辑区域背景颜色
    window.open() 弹出窗体居中
    javascript控制页面控件隐藏显示的两种方法
    (转)MyEclipse7.5.0版注册码破解及激活操作
    [置顶] Android代码读取 android 设备的电池信息
    [置顶] Android代码获得我们手机的cpu序列号
    [置顶] Android高手进阶教程Android常用名令集锦(图文并茂)!
  • 原文地址:https://www.cnblogs.com/reynold-lei/p/3187531.html
Copyright © 2011-2022 走看看