简体   繁体   English

如何使 python 服务器对 Linux 机器中的其他计算机公开?

[英]How to make python server public to other computers in a Linux machine?

I have an ubuntu computer and I want it to act as a server.我有一台 ubuntu 计算机,我希望它充当服务器。 How do I need to configure the ubuntu computer to be accessible from other computers?如何将 ubuntu 计算机配置为可从其他计算机访问? Let's say I have this very simple python TCP server:假设我有这个非常简单的 python TCP服务器:

from socket import socket

with socket() as server:
    server.bind(("", 5555))
    server.listen(5)
    print("[+] Server Listening")
    client, addr = server.accept()
    print(f"client connected from address {addr}")

How can I make this server public to other computers to connect?如何将此服务器公开给其他计算机以进行连接?

Well making a server publicly available is something that we need to know more details about your project.好吧,让服务器公开可用是我们需要了解有关您项目的更多详细信息的事情。 What do you mean about public??公众号是什么意思?? Do you want your server to be publicly available to internet??你想让你的服务器对互联网公开吗? Or you just want to use it in your local LAN????或者你只是想在你的本地局域网中使用它????

One way you can expose your local service publicly is by using some kind of application like localtunnel or ngrok公开本地服务的一种方法是使用某种应用程序,例如localtunnelngrok

Example with ngrok: ngrok http 5555 ngrok 示例:ngrok http 5555

Example with localtunnel: lt --port 5555 localtunnel 示例:lt --port 5555

These applications will open a tunnel on a random port locally and forward all the connections it gets on the application generated URL to the port you have specified.这些应用程序将在本地随机端口上打开一个隧道,并将它在应用程序生成的 URL 上获得的所有连接转发到您指定的端口。

Do not use these for production.不要将这些用于生产。 Not very reliable approach不是很可靠的方法

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在 python 建立公共服务器 - how to make a public server in python 如何公开 Python 服务器? - How do I make a Python server public? 如何通过python脚本检查NTP服务器是否在Linux计算机上运行 - How to check if NTP server is running on a Linux machine by a python script 如何使python在所有计算机上兼容? - How to make python compatible on all computers? 在其他Linux计算机上运行已编译的Linux可执行文件 - Running compiled Linux executable on other Linux computers 如何使我的 Python 程序提供的功能可用于在同一台计算机或其他计算机上运行的其他语言编写的程序? - How can I make the functions provided by my Python program available to programs written in other languages running on the same or other computers? 如何使用 Python 中的套接字库将我的服务器连接到其他机器? - How to connect my server to other machine using socket library in Python? 如何在没有python的情况下将我的Python脚本分发到其他计算机? - How to distribute my Python script to other computers without python? 如何在Python代码中修改文件路径,使其在其他计算机上工作? - How to modify a filepath in Python code so that it works on other computers? Python-在公共Internet协议上制作套接字服务器 - Python - Make socket server on Public Internet Protocol
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM