Search code examples
sslnginxwildcard-subdomain

Need help to get nginx to host server on wildcard domain


So I have been working on a project on a separate server for a company and now they want me to set it up for production with their SSL certificate and Key.

Here is my nginx.config file that is on the server I am working on
`

server{
    listen       443;
    ssl          on;
    ssl_certificate "/etc/pki/tls/certs/example.cer";
    ssl_certificate_key "/etc/pki/tls/certs/exampleKey.pem";
    #ssl_session_cache shared:SSL:1m;
    #ssl_session_timeout  10m;
    #ssl_ciphers HIGH:!aNULL:!MD5;
    #ssl_prefer_server_ciphers on;
    server_name snap.example.gov;


    # Load configuration files for the default server block.
    include /etc/nginx/default.d/*.conf;

    location / {
            proxy_pass http://localhost:80;
            proxy_redirect off;
            proxy_set_header Host $host ;
            proxy_set_header X-Real-IP $remote_addr ;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for ;
            proxy_set_header X-Forwarded-Proto https;
     }`

I've tried to follow all the tutorials but it still won't load over 'snap.example.gov'. I really need help to get this to load over https on the 'snap.example.gov' domain. What am I doing wrong? I'm still new to this so I'm not quite sure what to do.

Thank you guys in advance.


Solution

  • All the world is the internet and IP addresses are but its players. How does your computer know which computer server to connect to when you type 'snap.example.gov'? The answer is, it doesn't! Thus began the Domain Name System which affords your operating system the ability to go on the internet and query a series of well known servers that do know the IP address of every registered domain name on the internet. DNS knows that the IP address of stackoverflow.com is 151.101.65.69. Your computer doesn't.

    So, you have to register your server's domain name with those DNS servers and tell them what the IP address to access your site is. The fee for this service is as low as $11 or so but can be up to $50 assuming the name is available at all. example.gov, for example, is owned by the GSA of the United States government so you are not likely going to be able to register that name.

    There are a large number of domain name registrars and stackoverflow does not really like us to recommend one but searching for that will bring up some good ones.