I have a Django website in DigitalOcean, everything works fine expect routing example.com to www.example.com
I normally fix this using CNAME as the following, and all answers I have found also provide this, but it doesn't work in my case:
Hostname Alias Of TTL(Seconds)
www # 43200
This normally works in GoDaddy, but in DigitalOcean the www.example.com takes me to the welcome to Nginx page.
So how can I get the www.#.com to display the website?
To future enquirers, I found a solution.
When using gunicorn and nginx as I have done in DigitalOcean
In /etc/nginx/sites-available/site-name
server {
listen 80;
server_name .example.com;
in server_name add .example.com, with emphasies to the . before example.com
and make your CNAME record as I had described in the question.
Related
I have a domain example.com that i am trying to set up with caddy as a reverse proxy as well as static file host.
I have set up an a record pointing to the host ip with a wildcard record *
In my caddyfile i have this:
example.com {
root * somefiles
file_server
}
subdomain.example.com {
reverse_proxy 127.0.0.1:someport
}
I disabled ufw for this test
When i access example.com, i get an NXDOMAIN error. Pinging example.com gives me a host not found exception. However, accessing subdomain.example.com works fine and pinging it reveals the underlying ip
Anyone know the cause of this?
I'm trying to enforce the SSL protocol in a Jelastic Enviroment.
My setup is:
one node, with a Nginx Load balancer (+ public ip + custom ssl certificate) and a NodeJS application server.
The SSL setup is working, but i want to enforce the use of HTTPS no HTTP (a redirect).
I've tried to modify the nginx.conf but no success.
Any ideas how should I do that?
Create the config file /etc/nginx/conf.d/nginx_force_https.conf and add the lines below:
server {
listen 80;
server_name _;
return 301 https://$host$request_uri;
}
It will redirect all configured sites to https.
If you want only exact site example.com:
server {
listen 80;
server_name example.com;
return 301 https://example.com$request_uri;
}
Make sure that you have these includes enabled in /etc/nginx/nginx.conf
include /etc/nginx/nginx-jelastic.conf;
in /etc/nginx/nginx-jelastic.conf:
include /etc/nginx/conf.d/*.conf;
Check for errors in the configuration:
sudo service nginx configtest
Reload configuration (this would be enough to make changes "work"):
sudo service nginx reload
Check if all works as expected. Restart the whole webserver (if needed):
sudo service nginx restart
The detailed answer can be found in this post Force www. and https in nginx.conf (SSL)
I have one IP address on my Linux box, and would like to serve HTTPS websites in this form:
https://landing.example.com
https://site-01.example.com/index.html
https://site-01.example.com/files/index.html
https://site-01.example.com/store/index.html
https://site-02.example.com/index.html
https://site-02.example.com/files/index.html
https://site-02.example.com/store/index.html
Each of these websites is a Docker container on the same host, so my idea were setting up an NginX reverse proxy Docker container.
There are many howto's about NginX as reverse proxy, but what I want to do is different from the text book example, as I have HTTPS, multiple sub-domains and multiple URL's.
Questions
Does anyone know of howto's that deal with this type of setup, or perhaps can tell me what the technical key words I should search for are?
At this point I don't know where to start, so any help will be much appreciated.
You need to add A-records to you DNS manager that will redirect all your subdomains to the IP address of the host machine.
Then in your NGINX config you can do something like this.
server {
listen 80;
server_name landing.example.com;
location /static {
alias /home/example-dir/staticfiles;
}
access_log /home/example-dir/nginx-access.log;
error_log /home/example-dir/nginx-error.log info;
}
server {
listen 80;
server_name site-01.example.com;
location /static {
alias /home/example-dir2/staticfiles;
}
}
There are several questions on SO about nginx subdomain configuration but didn't find one that exactly the same as mine.
Say I got a virtual host some.example.com from higher-level net admin example.com at our organization. I want to use some.example.com as my primary site and use foo.some.example.com and bar.some.example.com for auxiliary usage (proxy, etc). I tried this simple configuration and put it under sites-enabled but didn't work:
server {
listen 80;
server_name some.example.com;
root /home/me/public_html/some;
index index.html index.htm;
}
server {
listen 80;
server_name foo.some.example.com;
root /home/me/public_html/foo;
index index.html index.htm;
}
server {
listen 80;
server_name bar.some.example.com;
root /home/me/public_html/bar;
index index.html index.htm;
}
In this setting some.example.com works fine, but for the other two browser return that could not find foo.some.example.com. I'm running it on a ubuntu server.
Is there something wrong with this configuration? Or is it something I should talk to higher level net admin (make foo.some.example.com and bar.some.example.com to be registered)?
Sub-domain configuration starts with an entry in the DNS server of the parent domain and the lookup resolves the sub-domain to an IP address of the web server. The web server in turn delegates the requests based on its configuration for the sub-domain.
If you don't have a DNS setup in your sub-domain, then the admin at example.com needs to set up a CNAME alias. The alias points the subdomain to the same web server, which hosts the website for the parent domain. The canonical names (CNAMES) are added for each of the subdomains. Once the subdomain is resolved to the IP address of the web server, the web server can route the request to a different website.
CNAME is just a way to get the web traffic to your IP address. The
request will still include the original name in the Host: header.
I'm trying to set up a Apache 2.2 to work with subdomains. I've got a domain example.de which correctly points to the IP, my site www.example.com works. Now I want a bugtracker under bugzilla.example.com. All I did was to add a vHost with Servername bugzilla.example.com, but that does not work - the error message is "Firefox can't find the server at bugzilla.example.com.". Why is that? example.com should point to the correct IP?
If you did only add the vhost the most probable problem is that you didnt add the Subdomain to your DNS - Zonefile.