I have many apps deployed per instance at AWS Opsworks. Each app has a domain or subdomain assigned to it.
It works fine when I type the domain/subdomain in the address bar in a web browser.
Although I would like to know how to access the domain/subdomain using the IP address in the address bar?
Eg:
http://[IP_ADDRESS]/[SOME_STRING_TO_ACCESS_DOMAIN_OR_SUBDOMAIN_1.COM]
http://[IP_ADDRESS]/[SOME_STRING_TO_ACCESS_MY_DOMAIN_OR_SUBDOMAIN_2.COM]
http://[IP_ADDRESS]/[SOME_STRING_TO_ACCESS_MY_DOMAIN_OR_SUBDOMAIN_3.COM]
http://[IP_ADDRESS]/[SOME_STRING_TO_ACCESS_MY_DOMAIN_OR_SUBDOMAIN_4.COM]
The web server is 'nginx' + 'unicorn'. Thanks in advance.
Just add the ip as a server name to the server, eg:
server {
server_name example.com 11.22.33.44;
# ...
}
If you want to handle the string after the ip in a different way, like ip/domain_name you need a separate server to handle this
server {
server_name 11.22.33.44;
root /path/to/root/$uri; # for example
# ...
}
Related
Can subdomains be used with ip on Nginx for testing, like teste.x.x.x.x
I did this but does not work.
server_name teste.x.x.x.x teste2.x.x.x.x ;
Thanks
I would say that is not possible, since an IP address is an entity by itself, and subdomains are a feature of DNS's structure or hierarchy.
However, for testing purposes, you could edit you /etc/hosts file, adding the following:
x.x.x.x teste.yourdomain.com
y.y.y.y teste2.yourdomain.com
and this way, accessing teste.yourdomain.com in your browser, would redirect your requests to x.x.x.x
We configured a load balanced URL that will direct the request from "sasstudiodev.org.com" to "http://abcd.org.com:7980/SASStudio" . Note that abcd and sasstudiodev do not have same ip address and sasstudiodev is a load balanced URL. Now we would like to ensure that the host name (i.e. abcd) is not visible to end users. Hence when a user types "sasstudiodev.org.com", SAS should connect to the available mid-tier node based on LB algorithm but the URL displayed in the address bar should NEVER expose the host name, ie. it should still show sasstudiodev.org.com/~/~
Is this possible using httpd or URL rewrite rules?
Yes, it is possible. In fact, you already have a load balancer/reverse proxy set up using Apache by default. To see it working, replace port 7980 to 8080. It is a default set up even when you have a single application server.
You need to change the settings for your virtual host and setup redirect, and should be ready to go.
I am building a regular django project - the difference is this:
I want the django website to only "work" on a specified subdomain - for example, http://www.foo.mydomain.com
I want to use an entirely different application to run on another specified subdomain - e.g. http://www.foobar.mydomain.com
How do I setup a django project, so that it only runs on a specific subdomain, and does not intercept requests to other subdomains - so other other applications can run on other subdomains on the same parent domain?
[[Note 1]]
The second application (running on the other subdomain is not a django app). In fact, it's mattermost, that I want to run on the other subdomain - so I can integrate mattermost into my website.
[[Note 2]]
I'm using nginx + gunicorn as the server
Use a separate server block for each domain. See this document.
server {
server_name www.foo.mydomain.com;
...
}
server {
server_name www.foobar.mydomain.com;
...
}
Where a server_name match cannot be found, nginx will use the default server. So define a catch-all server block to prevent nginx using one of the server blocks above.
server {
listen 80 default_server;
deny all;
}
Here is my setup.
Public site hosted by squarespace.com (www.example-domain.com)
Web application (AWS EC2/ELB), i would like to be available via the same domain. (my.example-domain.com)
Custom profile pages available as www.example-domain.com/username
My question is how can i setup the DNS to achieve this? If can't do it just through DNS, any suggestions? The problem i am facing is that if squarespace.com is handling the www.example-domain.com traffic how can i have it only partially handle it for certain urls. Maybe i am going about this in the wrong was all together though.
The two first are ok. As you mention, (1) is not compatible with (3) for a pure DNS config as www of example-domain.com has to be configured to a single end-point.
Some ideas of non-DNS workaround:
Having the squarespace.com domain on sqsp.example-domain.com and configure your www domain to a custom web server on which you configure the root (/) to redirect (HTTP 300) to sqsp.example-domain.com. It will be quite transparent for the user, except in his browser address.
The same but setting on / a full page HTML iframe containing sqsp.example-domain.com.
The iframe approach is a "less clean", Google the solutions to build your opinion.
EDIT:
As #mike-ryan mentioned, there is the proxy solution as well where you configure you web server to request another server to get the content to return to your user. If you are already using AWS, a smart way to do this is to use CloudFront: you can setup CloudFront to proxy one server on one URL and proxy another server on other URL. Actually, this is maybe the faster to way to implement you need. Of course, a proxy is one more "hop", so it may add more delay.
If you really want to have content served from different servers while only using a single domain name, you'll need to set up a proxy server to handle the request routing for you. I am assuming your custom profile pages must be served from your EC2 instance.
Nginx will receive all requests, and will then decide whether they should be sent to Square Space or your web app. Requests will be reverse proxied to Square Space or to your app, depending on the URL.
This is similar to #smad's answer, except it will all be invisible to the users which IMHO is better than redirecting the user to a new domain name.
Example steps:
Set up an Nginx server, create two virtual hosts - one for my.example.com, and one for www.example.com
Create two upstreams in your Nginx config - one for Square Space, and one for your app
Configure the www.example.com virtual host to reverse proxy connections to the Square Space upstream, if the URL is "/". Otherwise, traffic should be proxied to your app upstream [0]
Configure the my.example.com virtual host to proxy all traffic to your app upstream
[0] how to reverse proxy via nginx a specific url?
I want to recover from IP address change. My website used to be running fine, but after I allocated elastic IP address, it stopped working I want the website to be running again with new IP address.
So my question is: What steps must I consider and where should I look at first to recover from IP address change?
I can't access that website with old DNS address or new DNS address. Is this DNS issue?
Notes that might be helpful:
My web server seems to be using nginx, and I tried changing the configuration file with new dns, but that doesn't seem to do it.
When I access new domain name, it redirects to old domain name.
when I check with curl using curl -I http://localhost:80, it says HTTP/1.1 301 Moved Permanently
Just as an add on. The problem is this configuration change in your nginx file:
server {
listen 80;
server_name my.old.domain.com;
...
}
Has to be changed to:
server {
listen 80;
server_name my.new.domain.com;
...
}
So the DNS change can take up to 48 hours to propagate (it usually takes 10-30 minutes from experience, depending on your DNS provider)
When the DNS server wasn't propagated nginx would still redirect you to my.old.domain.com
Hope this helps.
Okay, I think it was just time issue.
After changing web server configuration (nginx), I waited around 28 hours and it suddenly started working again.
Source:
Subdomain IP address changed but client still getting directed to old site