[英]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.