I have found many suggestions around the net on this, but nothing that matches my exact issue. I have a webserver setup, that I have had our networking guys give me a DNS name for. Let's call it analytics.mycompany.com. This runs on port 80 and I have not issues.
A few months back I created an RStudio Shiny app that, by default, runs on port 3838. Therefore, I get to this via http://analytics.mycompany.com:3838/dashboard/. Which is all good and fine, but leadership has asked for an easier URL. I had my DNS guys give me an alias to the analytics.mycompany.com as dashboard.mycompany.com. Which, by default just points to the same port 80 website.
Now, I figure with a little apache/virtualhost/rewriterules/proxy I can tell apache to handle anything it receives from the dashboard.mycompany.com to just display the dashboard at http://analytics.mycompany.com:3838/dashboard/. After playing with this, I can get a URL like http://analytics.mycompany.com/dashboard/ to forward to the correct :3838 port and URL, but what I really want is for someone to be able to just enter http://dashboard.mycompany.com and just have the shiny dashboard appear. I know in DNS you cannot make aliases to ports, so that is out. I was hoping apache could handle this in some way, by saying, "ok, I have this URL on port 80 and I'm going to just display the content of this other site at port 3838."
I'm not sure if this is possible, but it is what I'd like. Right now my httpd.conf file for the virtual host at port 80 is as such:
<VirtualHost *:80>
ServerAdmin admin#mycompany.com
DocumentRoot /var/www/html
RewriteEngine on
RewriteCond %{REQUEST_METHOD} ^HEAD
RewriteRule ^/dashboard(.*) /foo/index.html
Redirect /dashboard http://analytics.mycompany.com:3838/dashboard
ProxyPass /dashboard/ http://analytics.mycompany.com:3838/dashboard
ProxyPassReverse /dashboard http://analytics.mycompany.com:3838/dashboard
</VirtualHost>
This was based on an example I found and is as close as I've come. I am thinking that I need some sort of virtual host for the new alias that might look like:
<VirtualHost dashboard.mycompany.com:80>
.....
</VirtualHost>
However, all the examples I find of VirtualHost is either *:80 or some IP addres like 192.168.0.1:80 or the like. If anyone has a suggestion or a way I can server this up at a simple URL, I would greatly appreciate it. Thank you so much!
To bring this to a close, this was a two part process:
I had to disable SELinux as it was interfering.
I created a VirtualHost entry as specified above (basically a port redirect)
Since we use a primary DNS, I had to have my network folks add an entry to InfoBlox for the domain.
After that, everything was working as expected. :)
Related
I have two servers running Apache2, one with an associated domain name, let's say "www.home.com" and another one only known by its IP address, let's say 10.11.12.13.
On www.home.com I have three web sites, configured through aliases in apache.
I have http://www.home.com, http://www.home.com/school, http://www.home.com/work.
All these sites are on the server www.home.com.
On 10.11.12.13, I have only one site, accessible by http://10.11.12.13/wiki
How can I configure apache to have http://www.home.com/wiki working but transparently (not changing URL) call http://10.11.12.13/wiki site ?
In other words, the user shall only see www.home.com/wiki/xxxxx when he uses the wiki.
What I have done:
On www.home.com : i have added a wiki folder with nothing in it, and an alias for www.home.com/wiki to work properly.
Then I have tried to use mod rewrite to replace 10.11.12.13 by www.home.com but that does not work, and I am not even sure to do it the right way.
For your information, mod rewrite is configured and works properly on both servers.
Someone could please help me on that ?
Maybe mod rewrite is not the right solution ?
Thanks !
Sam
I finally found a solution : the mod_proxy along with tags.
The conf that worked for me:
<VirtualHost *:80>
[...]
ServerName www.home.com
<Location /wiki>
Allow from all
ProxyPass "http://10.11.12.13/wiki"
ProxyPassReverse "http://10.11.12.13/wiki"
</Location>
</VirtualHost>
I have a simple webserver set up on an amazon ec2 instance, but the ip assigned to it must have been someone elses before because the logs are littered with requests to webpages and images that aren't there.
From the looks of it, the IP assigned to my webserver used to belong to a food blog or something, and a specific still-running website has linked to images that used to exist on this server. Is there any way to block all requests that are forwarded through this still-running website, or some other solution to clean up my log files/lessen the load on my server?
You can't really block them, but if your server is running on an EBS based instance you can:
stop the instance (right click on the instance in the AWS Console)
start the instance again.
You should get a new IP and you'll need to fix up your DNS to point to it.
Your site will be unavailable for a few minutes while this happens but hopefully the problem will go away, or at least become Somebody Else's Problem.
You can create a VirtualHost that has a ServerName and ServerAlias of the previously used domain-name. Then within, either block all access to this site or redirect all requests to where-ever you want.
<VirtualHost ip.address:80>
ServerName foodblog.com
ServerAlias www.foodblog.com
# 404 everything
order allow,deny
deny from all
#or redirect everything
Redirect / http://some.other.website/
</VirtualHost>
If the requests are mostly linked-to images, you could even create your own image that says 'take this link out' and redirect to it so it gets someone's attention.
I have a WAMP home web server up and running on a static IP and registered a domain with Namecheap, but I'm a bit shaky with DNS. At first I used URL Redirect and pointed it to my IP. This meant that when you typed in the domain (like example.com) it just redirected you right to my IP, replacing the domain name with it in the address bar. Now I'm trying to get the domain to show instead of the IP in the address bar, which I'm struggling to understand exactly how to do.
The latest thing I've tried which many people say to do is instead of using URL Redirect to use the A (Address) record type and point it to my IP, which I thought would finally fix my problems. Of course after 15 min or so when it all got updated I'm getting a 400 Bad Request with nginx under it in Firefox, and a blank page in Chrome. Now I'm getting blank pages in both. Did I do something wrong here? Do I need to edit something on the web server such as httpd.conf? Am I going at this completely wrong?
Yes you should do away with the redirect and instead create an "A record". The sub-domain entry would typically be, but is not restricted to "www". The record type "A" and destination/target would be your external IP address. Once you update this record it may take several hours before you notice it taking effecting, upon where on people typing your URL would be directed to your web server.
You will need to forward port 80 on your router to the server hosting WAMP.
Finally the WAMP server should be provided with your domain name so it knows which site to load. If use the VirtualHost file this will allow you to host multiple domains on your web server. To do this...
Uncomment the following line so it appears like below in your Apache httpd.conf, to allow Apache to use virutal hosts
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
Then locate the httpd-vhosts.conf file, should be found in your WAMP installation location, such as C:\wamp\bin\apache\apache*version_number*\conf\extra\
Add an entry for your site, altering the details to your own domain name and website location.
<VirtualHost *:80>
ServerName www.stackoverflow.com
ServerAlias stackoverflow.com
DocumentRoot "C:/websites/stackoverflow/"
ErrorLog "C:/websites/stackoverflow/logs/error.log"
CustomLog "C:/websites/stackoverflow/logs/access.log" common
</VirtualHost>
Now restart your WAMP server and give it a whirl.
Tip: If your server won't start after these changes, check that you have created the folder structure for the log files!
Solution described here could resolve this issue.
Most of the free dynamic dns providers, allow acquiring more than one free host name. If allowed you can solve the problem by getting a second name, e.g., mysite2.somefree.org.
Now, go and configure your free domain names in the dashboard of free provider in the following way (assume your IP is 188.165.15.29 and your server's listening to port 8085).
redirect mysite1.somefree.org to mysite2.somefree.org:8085
redirect mysite2.somefree.org to your dynamic IP, say, to 188.165.15.29
This also works when you are using Apache httpd server alone, not being part of WAMP. You do not need to tweak virtual host or any part of your server. You only configure inbound direction.
Use Forward with masking where you registered your domain. mine is GoDaddy.
in the forward settings, you will see this at bottom of the page. click Forward with masking and add the title you want them to see in the address bar of the browser when they go to your site. instead of showing your IP address
I'm wondering if anyone can help me define a new local VirtualHost using Apache.
The goal is to have a site that is viewable only from the local network (hidden behind a firewall). Right now I have Webmin installed and it runs on transaction:10000. I am trying to get the other site running on transaction:7000.
The following does not work:
DocumentRoot /var/path
Is there a better way to do this? I'm new to Apache and trying to figure this out.
Summary: Need local /var/path directory to run on a port other than 80 for local access only.
I'm assuming that you don't know to Apache Virtual Host Code. I will show you how to use it. If this didn't help you please don't hesitate to reply to me.
You must place code in your HTTPD.CONF which can be found in the conf folder. If your file is called wwwroot instead just change the name in the code below BUT DO NOT CHANGE THE NAME OF THE FOLDER!!!
NameVirtualHost 111.22.33.44
<VirtualHost *:7000>
ServerName www.domain.tld
ServerPath /domain
DocumentRoot /htdocs/domain
</VirtualHost>
What does this mean? It means that a request for any URI beginning with "/domain" will be served from the virtual host www.domain.tld. This means that the pages can be accessed as domain.tld/domain/ for all clients, although clients sending a Host: header can also access it as domain.tld/.
In order to make this work, put a link on your primary virtual host's page to http://www.domain.tld/domain/. Then, in the virtual host's pages, be sure to use either purely relative links (e.g., "file.html" or "../icons/image.gif") or links containing the prefacing /domain/ (e.g., "http://www.domain.tld/domain/misc/file.html" or "/domain/misc/file.html").
So all domains will be pointed to your IP address and based on the domain name if it is "www.domain.tld" it will take you to the folder "/htdocs/domain" or "/wwwroot/domain"
EDIT:
<Directory "/var/path/">
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
</Directory>
This lets access to the "/var/path/" folder from only localhost which is where Apache is configured which is on your computer!
Good Luck!!!
First of all, sorry if I got the term 'pseudo subdomain' wrong.
what I am trying to achieve is this-
When someone registers on my application, they get a new url like..
yourname.myapp.tld
I dont want to use the subdomain system for this. To be frank, I dont know how the subdomains exactly work but it guess it requires a folder per subdomain inside the document root and then the server redirects the requests there.
Can this be achieved by doing something like -
when a visiter types any subdomain, (anything.myapp.tld), he is able to access myapp . In the index.php file i will explode the $_SERVER['HTTP_HOST'] to get the subdomain which i will store in session and will thereafter act as an identifier for that user. Ideally i wouldnt want to create any vhosts or add many lines to the hosts file. Can this be achieved with just one vhost?
Is this possible with mod rewrite or something ?
Yes you can archive this using wildcard that needs to be configured on both, the dns server and http server
On the dns a entry like this (installing dns on ubuntu https://help.ubuntu.com/10.04/serverguide/C/dns.html):
; wildcard subdomains are all directed to this IP
; of course this should be the IP of your web server
*.domain.tld. IN A 1.2.3.4
At apache an entry like this:
<VirtualHost 111.22.33.55>
DocumentRoot /www/subdomain
ServerName www.domain.tld
ServerAlias *.domain.tld
</VirtualHost>
What happens after is that everything.domain.tld will be going to your main folder so you can use the index.php to redirect it to the right place or even an htaccess using mod_rewrite.