How to make an ipfs daemon into a public gateway?

I am accessing ipfs from an Azure server. In order to view it on my web browser, I changed the API and the Gateway access from 127.0.0.1 to 0.0.0.0 using the commands:
ipfs config Addresses.API /ip4/0.0.0.0/tcp/5001
ipfs config Addresses.Gateway /ip4/0.0.0.0/tcp/8080

The command ipfs daemon gives the following logs:

Initializing daemon…
Successfully raised file descriptor limit to 2048.
Swarm listening on /ip4/10.0.0.4/tcp/4001
Swarm listening on /ip4/127.0.0.1/tcp/4001
Swarm listening on /ip6/::1/tcp/4001
Swarm listening on /p2p-circuit/ipfs/QmZtmKSApr3v9pxY95dd25kq5BRMF5saLtRwTBTuazhpjU
Swarm announcing /ip4/10.0.0.4/tcp/4001
Swarm announcing /ip4/127.0.0.1/tcp/4001
Swarm announcing /ip6/::1/tcp/4001
API server listening on /ip4/0.0.0.0/tcp/5001
Gateway (readonly) server listening on /ip4/0.0.0.0/tcp/8080
Daemon is ready

Yet the url http://my_ip_address:5001/webui gives “site cannot be reached”. What should I do?

Did you open the relevant ports to your Azure VM?

Note that you only need the gateway port opened to run a gateway. I think exposing the API port is not recommended.

Yeah, the relevant ports are opened

What do you get if you run telnet your.ip.address.here 8080 from a remote machine?

Assuming the Azure-specific setup is correct, maybe there’s a local firewall blocking those ports.

Trying my_ip_address_here…
telnet: Unable to connect to remote host: Connection timed out

There’s something discarding connection attempts to your gateway port, then.

How are you applying the Azure network security group with port 8080 open to your VM? Are you applying it to the subnet that the VM is on or did you apply it to a virtual interface?

What does the output from iptables -L -n show on your VM? That should give us an idea of whether the VM’s firewall is blocking the connection.

Maybe you can try change the Addresses.API and Addresses.Gateway directly to your IP address.
I was using a LAN network, at first the two addresses are both set to 127.0.0.1. It works for http://localhost:8080/ipfs/[hash], but http://[ip address]:8080/ipfs/[hash] dosen’t work.
I changed the config file to :
“API”: “/ip4/[ip address]/tcp/5001”,
“Gateway”: “/ip4/[ip address]/tcp/8080”
and it works.

Hope this can do some help for your problem

Based on the earlier output the gateway is already listening on all interfaces (0.0.0.0).

You have to use the public IP of the server

Why? 0.0.0.0 should listen on all interfaces.