简体   繁体   English

如何使用自定义域访问自己的ogar服务器?

[英]How to access my own ogar server by using a custom domain?

I followed the instruction and installed Ogar on my CentOS server successfully. 我遵循了说明,并将Ogar成功安装在CentOS服务器上。 But every time when my friends want to play on my server they have to use a google chrome and go to command lines and type 'connect("ws://agar.davidchen.com:443")'. 但是每次我的朋友想要在我的服务器上玩时,他们都必须使用Google chrome并转到命令行并输入'connect(“ ws://agar.davidchen.com:443”)'。 It's not cool, because they think how the things work is you type a domain name (like 'agar.davidchen.com') then you can play the game, just like typing 'agar.io'. 这不是很酷,因为他们认为事情的原理是您输入一个域名(例如“ agar.davidchen.com”),然后您就可以玩游戏了,就像输入“ agar.io”一样。 Is there any solution to this issue? 这个问题有解决方案吗? Thanks! 谢谢!

You need to proxy the requests from HTTP to your socket connection via a web server like Nginx, so you can use http://agar.davidchen.com to access your web socket. 您需要通过Nginx之类的Web服务器将HTTP请求代理到套接字连接,因此可以使用http://agar.davidchen.com来访问Web套接字。

Install Nginx (version >= 1.3), then configure your virtual host with something like this: 安装Nginx(版本> = 1.3),然后使用以下配置虚拟主机:

map $http_upgrade $connection_upgrade {
    default upgrade;
    '' close;
}

upstream websocket {
    # This is where your web socket runs
    server 127.0.0.1:443;
}

server {
    listen 80;
    server_name agar.davidchen.com;
    location / {
        proxy_pass http://websocket;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $connection_upgrade;
    }
}

Reference: https://www.nginx.com/blog/websocket-nginx/ 参考: https : //www.nginx.com/blog/websocket-nginx/

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

相关问题 如何使用服务器域名从本地计算机访问我的nodejs Web服务器? - How can I access my nodejs web server from my local computer using the server domain name? 如何在nodejs中使用我的服务器域发送电子邮件 - how to send an email using my server's domain in nodejs 正确的方法来在服务器上存储我自己的访问令牌/秘密 - Proper way to store my own access tokens/secrets on server 如何使用我自己的自定义身份验证服务使用团队机器人对用户进行身份验证? - How to authenticate a user using a teams bot using my own custom authentication service? 如何知道我的lambda绑定的自定义域? - How to know the custom domain my lambda is bound to? 如何使用自己的身份验证系统控制对 Google Cloud Storage 对象的访问? - How could I control access to Google Cloud Storage objects using my own auth system? 如何将我的Google Assistant应用连接到我自己的服务器 - How to connect my Google Assistant app to my own server 如何让我的用户在我的应用程序中访问他们自己的存储桶 - how to make my users access to their own bucket in my application 如何将 JSON 文件转换为对我自己服务器的响应 - How to convert the JSON file as a response to my own server 如何在Nodejs服务器上安装自己的字体? - How do I install my own fonts on Nodejs Server?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM