-1

So, I got a domain, suputamadre.es

I launched a google cloud instance and assigned an IP to it, say 1.2.3.4

I launched my django server to listen on 0.0.0.0:80

I try to connect by going on chrome to http://1.2.3.4 or http://1.2.3.4:80 and it works. Great.

Set up my domain on Google Cloud DNS (domain bought from GoDaddy, so pointed the nameservers to Google Cloud)

Set up an A record suputamadre.es pointing to 1.2.3.4

Going to cmd and doing a ping suputamadre.es returns 1.2.3.4

Going in a browser and writing suputamadre.es returns a Connection refused error, however suputamadre.es:80 works. Why is that? How can I just point this domain to my server? Tried doing a CNAME, didn't work either...

While on topic, is there any way of pointing it to both :80 and :443 to support SSL without running two concurrent servers? Or even point the domain to 1.2.3.4:8000 without having to use a redirect given that SRV don't work in browsers?

Thanks a bunch. I've been stuck on this for two days now, and whatever I try to google doesn't seem to work for me. Not to mention that if I google something about "DNS A register" google thinks I'm talking about a register...

  • You don't have a server listening on port 443 (i.e. `https`), while there is one running on port 80 (i.e. `http`). `A` records point just to an IP address, no port. `SRV` records contain a port, but they are not used with `HTTP/HTTPS`, that by default use port `80` and `443`. – Piotr P. Karwasz Jan 17 '20 at 00:29

2 Answers2

1

It seems like your problem is partially solved. If I put http://suputamadre.es into my browser I can see your "Django setup complete" page, so that seems to be working.

With regards to the :80 vs :443 SSL question, this is typically done with a redirect on the port 80. IE: A user types in http://suputamadre.es which is received by your webserver on port 80 and then the web server sends back a redirect to https://suputamadre.es (which is served on port 443 by default which the browser will use without having to specify it). This way all traffic is served via https on port 443. Anything to port 80 is redirected to port 443.

DrewZa
  • 56
  • 5
0

As DrewZa indicated, you can use nginx for these purposes. It's a nice lightweight webserver. Look here:

Installing NGINX Plus on the Google Cloud Platform

As for port forwarding from 80 to 443:

create a server entry in your nginx.conf file and you can do the following:

server {
    listen       80;
    server_name  suputamadre.es;

    proxy_set_header X-Real-IP $remote_addr;

    location / {
        rewrite ^ https://$host$uri permanent;
    }
 }

This will redirect all requests from 80 to 443

Paul
  • 125
  • 6