Certbot: No valid ip addresses found / Invalid response found (From Google Cloud) - google-cloud-platform

I got this cmd:
sudo certbot --apache -d pushupteam.dev -d www.pushupteam.dev
and this is. what I got :
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator apache, Installer apache
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for pushupteam.dev
http-01 challenge for www.pushupteam.dev
Enabled Apache rewrite module
Waiting for verification...
Cleaning up challenges
Failed authorization procedure. www.pushupteam.dev (http-01): urn:ietf:params:acme:error:un
authorized :: The client lacks sufficient authorization :: Invalid response from http://www
.pushupteam.dev/.well-known/acme-challenge/j4gaJn6vX6tvEGu0HQagjT69Oc3R7l_VJ8CgaluAnLk [34.
89.161.114]: "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\n<html><head>\n<title>40
4 Not Found</title>\n</head><body>\n<h1>Not Found</h1>\n<p", pushupteam.dev (http-01): urn:
ietf:params:acme:error:dns :: No valid IP addresses found for pushupteam.dev
IMPORTANT NOTES:
- The following errors were reported by the server:
Domain: pushupteam.dev
Type: None
Detail: No valid IP addresses found for pushupteam.dev
- The following errors were reported by the server:
Domain: www.pushupteam.dev
Type: unauthorized
Detail: Invalid response from
http://www.pushupteam.dev/.well-known/acme-challenge/j4gaJn6vX6tvEGu0HQagjT69Oc3R7l_VJ8C
galuAnLk
[34.89.161.114]: "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML
2.0//EN\">\n<html><head>\n<title>404 Not
Found</title>\n</head><body>\n<h1>Not Found</h1>\n<p"
To fix these errors, please make sure that your domain name was
entered correctly and the DNS A/AAAA record(s) for that domain
contain(s) the right IP address.
I have the Domain from Namecheap & I use google cloud DNS.
what is the Problem? I have only interest in ipv4 so no AAAA record;
also, my ufw is disabled (like all google VMs)
Edit:
my etc/apache2/sites-available/srv.conf
<VirtualHost *:80>
ServerAdmin admin#pushupteam.dev
DocumentRoot /var/www/html/
ServerName pushupteam.dev
<Directory /var/www/html/>
Options +FollowSymLinks
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog /var/log/apache2/codeigniter-error_log
CustomLog /var/log/apache2/codeigniter-access_log common
</VirtualHost>
I use Ubuntu 18.04 LTS and Apache
Edit 2:
pushupteam.dev. NS 3600 ns-cloud-b1.googledomains.com.
ns-cloud-b2.googledomains.com.
ns-cloud-b3.googledomains.com.
ns-cloud-b4.googledomains.com.
pushupteam.dev. SOA 3600 ns-cloud-b1.googledomains.com.
cloud-dns-hostmaster.google.com.
1 21600 3600 259200 300
www.pushupteam.dev. A 60 34.89.161.114
should I reconfig my DNS?
Edit 3:

I encountered this error when trying to set up SSL for an application running in a DigitalOcean droplet.
When I run the command:
sudo certbot --nginx -d example.com -d www.example.com
I get the error:
No valid IP addresses found for www.example.com
OR
During secondary validation: No valid IP addresses found for www.example.com
Here's how I solved it:
Confirm that you have an A record pointing to your server’s public/floating/elastic/static IP address for the domain names that you are having issues with.
Say you want to obtain a certificate for example.com and www.example.com, ensure that they both have an A record pointing to your server’s public/floating/elastic/static IP address.
If you confirm that they are correctly set and you're still having the errors, then give it sometime, say, 30 mins to 1 hour and then try again, or better still run the certificate generation for the eligible domains, say :
sudo certbot --nginx -d example.com
once it becomes successful, run it again with all the domains you want to use to expand/modify it:
sudo certbot --nginx -d example.com -d www.example.com
Resources: No valid IP address found for domain when trying to get SSL certificate?
That's all.
I hope this helps

In order to run this command:
sudo certbot --apache -d pushupteam.dev -d www.pushupteam.dev
Then you need to add a DNS A resource record in your DNS server:
pushupteam.dev A 3600 34.89.161.114
Note: Do not set short TTL values for NS records. Typically this should be one day (86,400 seconds). For A records, one hour (3600 seconds) is normal. You can set these values to just about anything. Consider performance, cache timeouts, and cost.
For the Apache configuration file: /etc/apache2/sites-available/srv.conf add the line:
ServerAlias www.pushupteam.dev
and restart the Apache server:
sudo systemctl restart apache2
I am assuming that you correctly enabled srv.conf by running a command similar to a2ensite srv. Normally the configuration filename is the hostname.
To double check enabled virtual hosts, run this command:
apache2ctl -S
Make sure that both hostnames pushupteam.dev and www.pushupteam.dev are responding to normal web browser requests.

Add a line in your Apache configuration file after the ServerName;
ServerAlias *.pushupteam.dev
and try again.
If that doesn't work also change the "A" type record - from www.pushupteam.dev to just pushupteam.dev.

For me after setting the A/AAAA records the config continued failing so I've restarted nginx first:
sudo systemctl reload nginx
and then reexecuted the command
sudo certbot --nginx -d example.com -d www.example.com
And voilà.

Related

Domain Name Changes Back to Static IP

I have been trying to solve this issue for the past days, but haven't been able to fix it. The problem is that my domain name redirects me to my static ip address, but as soon as the page is loaded, the url displays the ip.
Some context:
I am running a django-based application in AWS Lightsail, which uses Apache 2 as the web-server. I have created a virtual host that serves port 80.
The domain name I bought it using GoDaddy, and currently points to this static ip. My intuition tells me that the problem is not with the domain service provider because it does redirect my traffic to the ip. However, one thing to consider is that I have not changed the nameservers at Godaddy, would this be the root problem?
My httpd.conf file looks like this, in AWS is named bitnami.conf:
<VirtualHost _default_:80>
WSGIScriptAlias / /opt/bitnami/apps/django/django_projects/myApp/myApp/wsgi.py
ServerName myApp.ca
<Directory /opt/bitnami/apps/django/django_projects/myApp>
AllowOverride all
Require all
grantedOptions FollowSymlinks
</Directory>
DocumentRoot /opt/bitnami/apps/django/django_projects/myApp
Alias /static/ /opt/bitnami/apps/django/django_projects/myApp/static/
<Directory /opt/bitnami/apps/django/django_projects/inVerte/static>
Require all granted
</Directory>
</VirtualHost>
I have tried adding other directives such as:
RedirectPermanent / http://myApp.ca/
Redirect /index http://myApp.ca/
RewriteEngine On
RewriteCond %{HTTP_HOST} !^myApp.ca$
RewriteRule /.* http:/myApp.ca/ [R]
However, they only cause a 502 error.
I tried running this command curl -I "mydomain.com".
Output:
HTTP/1.1 301 Moved Permanently
Server: nginx/1.16.1
Date: Wed, 05 Aug 2020 21:42:24 GMT
Content-Type: text/html; charset=utf-8
Connection: close
I tried using "sudo /opt/bitnami/ctlscript.sh status"
Output:
apache already running
mysql already running
postgresql already running
The last thing I have done: I updated the A record in my DNS settings at Godaddy, so I made sure that the domain name is translated to the IP. Moreover, I have configured forwarding with masking. However, this lead me to the following error when visiting the site:
Website will not allow Firefox to display the page if another site has embedded it
https://support.mozilla.org/en-US/kb/xframe-neterror-page?as=u&utm_source=inproduct

Access Local Domain Name Website as API server in WAMP

I have two local Domain which work fine, however, the otherA domain is the API server that the otherB domain consumes API. The problem is it can't access the otherA domain, and returns network error something like
option 1
let apiserver = 'http://localserverA.local'
axios.get(`${apiserver}/apicall`).....
catch( ---> return network error
But this works
option 2
let apiserver = 'http://127.0.0.1:8000'
axios.get(`${apiserver}/apicall`).....
returns 200 ok
The problem with option 2 is to run php built in server which not a good idea because some set up in databases requires domain local host to access its data.
<VirtualHost *:80>
ServerName localserverA.local
ServerAlias localserverA.local
DocumentRoot C:/projects/r/projects/A/web
<Directory "C:/projects/r/projects/A/web">
AllowOverride All
Require all granted
Allow from All
Allow from 127.0.0.1
Allow from ::1
#FallbackResource /app.php
</Directory>
</VirtualHost>
I can even ping my domain name, it works well in browser but got network error when endpoint called via javascript. Works well in production
Any Idea?
This may help you:
Go to directory (from where your landing page load, if you have laravel project you need to go to public directory) to your project in command promt and fire command.
php -S <ip addresss>: <any port no>
like this
php -S 192.168.1.62:4200
Now you can access that project using 192.168.1.62:4200
You need to change your %SystemRoot%\system32\drivers\etc\hosts file. Add next line:
127.0.0.1 localserverA.local

setup sub domain amazon using Route 53

im really confused regarding setting up sub domain on amazon using their DNS service (hosted zones) and another 3rd party registrar. This is because i found different solutions some include add CNAME record and others say add using virtual host in the apache server
so should i do both or adding the CNAME in the records is enough.
so far, I have tried the first solution
I have added CNAME record (for example, let s assume my website is example.com)
so I have added CNAME subdomain.example.com pointing to example.com/subdomain. I have waited for 1 day so the DNS settings to be propagated, still when I check the website i get an error.
i've also tried to add virtual host in my conf file, but it didn't work at all.
I think the answer is very clear in the referenced link, but to clarify more what you should do , Follow the following steps:
1 - Go to your AWS managment console -> Route 53.
According to your question, it looks that you are already using AWS DNS service, which means you have already created hosted zone (in case you don't have hosted zone create one )
For more info, follow the documentation http://docs.aws.amazon.com/Route53/latest/DeveloperGuide/creating-migrating.html
2 - Click on the hosted zone, then click on create record set
the record set should be type A pointing to your #IP of your server (Elastic IP or Load balancer IP)
Example:
subdomain.example.com -> Type A -> #IP
By the way you can use CNAME record for www.subdomain.example.com that points to subdomain.example.com
3 - the last step is to add Virtual Host in your configuration file of your appache server.
open this file /etc/httpd/conf/httpd.conf.d
Add the following Virtual Hosts
<VirtualHost *:80>
ServerAdmin webmaster#yourdomain.com
DocumentRoot "/var/www/html/domain_folder"
ServerName example.com
ErrorLog "logs/example.com-error_log"
CustomLog "logs/example.com-access_log" common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster#yourdomain.com
DocumentRoot "/var/www/html/subdomain_folder"
ServerName subdomain.example.com
ErrorLog "logs/subdomain.example.com-error_log"
CustomLog "logs/subdomain.example.com-access_log" common
</VirtualHost>
4 - Restart httpd by typing this at the command line:
> sudo service httpd restart
PS :
=> if this doesn't work, here is one possible cause. There might be another configuration file interfering with this one. Check for another .conf file in /etc/httpd/conf.d. Often your primary httpd.conf will include another .conf file in this directory. Make sure it doesn’t have some Virtual Host settings which are interfering with yours. If so, comment them out.
=> also make sure NameVirtualHost *.80 is uncomment

Configure Nginx To Accept Domain Name

I bought a Domain Name today, changed the DNS to match the exact VPS IP and configured Nginx to run my app.
So far, I can connect to my app using the external ip, from any computer, but I still can't connect to it via the Domain Name.
I've set the server_name to be the exact domain name I purchased, is there anything left I must do?
it is DNS configuration problem.
for sure about reason open putty and see output about site content by curl or wget or lynx.
example:
lynx mysite.com
if it work and returned proper result nginx config is true but it is DNS problem.
dns problems:
/etc/hosts
/etc/hostname
bad configuration
try ping sitename.com on your pc with ms dos. if has timeout then its not nginx problem.

Route a specific path to a specific EC2 instance using Route 53

I'm not sure if this is even possible, but if so I'm looking for the best way to do it.
Say I want to host my blog for example.com on it's own EC2 instance, and I want the path to my blog to be example.com/blog
Is it possible to route all requests to example.com/blog/* to one instance, and all other requests to that domain elsewhere?
My web server is Apache.
Thanks!
You can now do this with Application Load Balancer and path-based routing: https://docs.aws.amazon.com/elasticloadbalancing/latest/application/tutorial-application-load-balancer-cli.html#path-based-routing-aws-cli
Certainly it's possible, but not with DNS nor with an ELB. The most common solution to this is to use a web server that issues a 301 or 302 redirect.
In your case, example.com would point to whatever the main site is. The web server (nginx or Apache httpd, perhaps) hosting example.com would have a redirect for example.com/blog/* that is found at another destination.
Here's an SO post on using Nginx for a redirect and for using Apache for a redirect.
Yes, but you would have to proxy your requests through an instance handling example.com. How you configure this depends on your web server.
Some examples on how to configure this:
nginx: http://wiki.nginx.org/HttpProxyModule
Apache: http://httpd.apache.org/docs/2.2/mod/mod_proxy.html
Since you are using Apache2 Server, so you can achieve this very easily by creating a Virtual Host.
sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/vchost1.com.conf
Create Virtual Configuration using the above command, it copies the complete code of content from the default file provided by the apache2 Server.
sudo nano /etc/apache2/sites-available/vchost1.com.conf
start configuring host & domain according to your requirements
<VirtualHost *:80>
ServerAdmin admin#domain.com
ServerName domain.com
ServerAlias www.domain.com
DocumentRoot /var/www/domain.com/public_html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
here also, you can multiple Virtual Host configurations in a single file, start configuring and enjoy hacking.
you can also multiple web applications in a single instance by using the same method and theis reference.
https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-18-04-quickstart