我最近在 AWS 上设置了一个闪亮的服务器帐户。我有一个格式为 xx.xxx.xxx.xxx 的弹性 IP,但我需要添加端口号:3838 才能在网络上查看它
我希望将 dns 名称 mywebsite.com 与弹性 ip 相关联,但显然不希望每次都有用户添加:3838。我尝试使用 go daddy 将名称与弹性 ip+:3838 相关联,但这是无效的
TIA
我最近在 AWS 上设置了一个闪亮的服务器帐户。我有一个格式为 xx.xxx.xxx.xxx 的弹性 IP,但我需要添加端口号:3838 才能在网络上查看它
我希望将 dns 名称 mywebsite.com 与弹性 ip 相关联,但显然不希望每次都有用户添加:3838。我尝试使用 go daddy 将名称与弹性 ip+:3838 相关联,但这是无效的
TIA
您必须在服务器上设置反向代理。您可以使用 Apache 或 nginx 来完成。
使用 Apache,您可以在配置中添加如下内容:
<VirtualHost *:80>
ProxyPass / https://127.0.0.1:3838/
ProxyPassReverse / https://172.0.0.1:3838/
</VirtualHost>
使用 nginx:
server {
listen 80;
server_name myserver.com;
location / {
proxy_pass http://127.0.0.1:3838;
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
proxy_redirect off;
proxy_buffering off;
proxy_set_header Host static.example.com;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
如果你在 ubuntu 上工作,你可以使用iptables
sudo iptables -t nat -I PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 3838
这会将来自端口 80 的所有流量路由到端口 3838