I'm not sure how best to describe this (as you can clearly tell from the title) so I'll give you an example:
I have a multisite Drupal installation. Each of the sites' sitemap.xml files are located on the server at /sites/example.com/files though with a browser (and to search engines) it is accessible at example.com/sitemap.xml
I was wondering how this was achieved? Is this called Virtual Directory?
Thank you
They are VirtualHost , if you install a multi site Drupal, you must Apache (or other web server) with different virtual hosts.
This virtual hosts resides in different directory and respond to different domain names! The trick is done by your webserver.
For drupal check: http://drupal.org/node/43816
Related
Preface: I'm new to the whole web hosting thing, so I apologize if any information I give doesn't make sense or is inaccurate. I will do my best to explain things.
I currently have a self-hosted server running Windows Server 2019 that is hosting two sites via IIS. I recently have created an application that runs on a Docker container instance that hosts a website on port 40444. I would like to access this site via a specific subdirectory on my website instead of the port (www.mywebsite.com/website3 instead of www.mywebsite.com:40444). For clarification, here is an example of what I'm looking to do:
www.mywebsite.com/website1 (hosted on IIS)
www.mywebsite.com/website2 (hosted on IIS)
www.mywebsite.com/website3 (hosted on docker via port 40444)
I was able to get a basic reverse proxy set up and successfully got the docker application to show on localhost/, but I would prefer using a subdirectory if possible.(image below).
I attempted to change (.*) to (.*)website3$ and it did what I wanted, but the website cannot load any files (i.e css, js, etc.) and gives me the following error
https://www.mywebsite.com/css/style.css net::ERR_ABORTED 404 (Not Found)
If IIS isn't the best option to accomplish what I need I am more than happy to use a different solution. As I mentioned before, I'm new to web hosting and it was just the simplest to set up.
I have an ASP.net MVC 5 aplication with VS2017.
I would like to load some pictures from a network path (the pictures should not be included to the project folder structure).
I know how to add a virtual directory in IIS on my server where the application is finally running. But I dont know how to setup the same on my local computer.
On the server I can setup an Alias and a physical path.
But in my project in VS2017(properties/web) I can only press the button "create virtual directory" next to project url "http://localhost:51138/".
Can maybe someone explain how to setup an virtual directory on localhost for testing? Thank you so much.
You are using the Visual Studio Development Server which does not allow virtual directories. You can do what you want with a local copy of IIS, creating a website that points to your development folder, and creating the virtual directory you want in that website.
Install a local copy of IIS. This is available to you in the
Professional version of Windows.
Open IIS Manager, create a new website, and set the Physical
Path to your development folder.
Add a binding for this website with the Host name set to a domain name you want to use for
testing. I generally use ".loc" as the TLD. For example, the
production website domain of "mywebservice.com" would be
"mywebservice.loc". Use port 80 in the binding.
Modify your local hosts file at
C:\Windows\System32\drivers\etc\hosts to include this line. Replace
"mywebservice.loc" with whatever domain you chose to use above mywebservice.loc 127.0.0.1
In your VS project properties, set Web-->Servers to Use Custom Web Server and
set the Server Url to mywebservice.loc or whatever domain you chose above.
Now you can add a virtual directory just as you do in production.
I do this for all my website development primarily because nothing will happen in production that does not happen locally. You can even test using real SSL certificates this way.
Just create a folder in the directory of your project to mimic what will be a virtual directory and then copy some test files there.
For example, create a documents directory in your project directory. So the referenced path in your project will be something like ~/documents/somefile.pdf
The server's virtual directory documents can then point to some some other network location.
Let's say we have 2 separate applications, a Web Api application and a MVC application both written in .NET 4.5. If you were to host the MVC application in IIS under the host header "https://www.mymvcapp.com/" would it be possible to host the Web Api application separately in IIS under the host header "https://www.mymvcapp.com/api/"?
The processes running the 2 applications in IIS need to be separate. I know of the separate methods of hosting, self hosting and hosting using IIS. I would like to use IIS if at all possible.
Also, how would I host two applications (an API and a web application) if each were on a separate server so that I could serve the api from http://www.mymvcapp.com/api?
There are at least 4 ways of doing what you want to do. The first two methods are for if you have 1 web server, and both applications are served from that one web server running IIS. This method also works if you have multiple web servers running behind a load-balancer, so long as the API and the Web site are running on the same server.
The second two methods are using what's called a "Reverse Proxy", essentially a way to route traffic from one server (the proxy server) to multiple internal servers depending on what type of traffic you're receiving. This is for when you run your web servers on a set of servers and run your API on a different set of servers. You can use any reverse proxy software you want, I mention nginx and HAProxy because I've used both in the past.
Single Web Server running IIS
There are two ways to do it in IIS:
If your physical folder structure is as follows:
c:\sites\mymvcapp
c:\sites\mymvcapp\api
You can do the following:
Create a Child Application
Creating a child application will allow your "API" site to be reachable from www.mymvcapp.com/api, without any routing changes needed.
To do that:
Open IIS Manager
Click on the appropriate site in the "Sites" folder tree on the left side
Right Click on the API folder
click "Convert to Application"
The downside is that all Child Applications inherit the web config of their parent, and if you have conflicting settings in there, you'll see some runtime weirdness (if it works at all).
Create a directory Junction
The second way is a way to do it so that the applications maintain their separateness; and again you don't have to do any routing.
Assuming two folder structures:
c:\sites\api
c:\sites\mvcapp
You can set up Junctions in Windows. From the command line*:
cd c:\sites
mklink /D /J mymvcapp c:\sites\mvcapp
cd mymvcapp
mklink /D /J api c:\sites\api
Then go into IIS Manager, and convert both to applications. This way, the API will be available in \api\, but not actually share its web.config settings with the parent.
Multiple Servers
If you use nginx or haproxy as a reverse proxy, you can set it up to route calls to each app depending.
nginx Reverse Proxy settings
In your nginx.conf (best practice is to create a sites-enabled conf that's a symlink to sites-available, and you can destroy that symlink whenever deploying) do the following:
location / {
proxy_pass http://mymvcapp.com:80
}
location /api {
proxy_pass http://mymvcapp.com:81
}
and then you'd set the correct IIS settings to have each site listen on ports 80 (mymvcapp) and ports 81 (api).
HAProxy
acl acl_WEB hdr_beg(host) -i mymvcapp.com
acl acl_API path_beg -i /api
use_backend API if acl_API
use_backend WEB if acl_WEB
backend API
server web mymvcapp.com:81
backend WEB
server web mymvcapp.com:80
*I'm issuing the Junction command from memory; I did this a few months ago, but not recently, so let me know if there are issues with the command
NB: the config files are not meant to be complete config files -- only to show the settings necessary for reverse proxying. Depending on your environment there may be other settings you need to set.
I set up a virtual host in a Linux server running Webmin 1.580. I gave it a server name and a document root directory. How do I access the website under the virtual host from the internet?
Am I supposed to type the server's IP address and then the name? That's not working. It says:
Error - File not found
Is there anything else I need to do to make my site live on the server?
You should probably be using Virtualmin, in addition to Webmin, if you're going to be doing web hosting with the system. It makes most elements of the process a lot easier. The installation script will install all of the additional software you need (like BIND), and provides a friendlier GUI for web hosting tasks.
You can download it here: http://www.virtualmin.com/download
It is available in a free Open Source version, and is developed by the same people as Webmin.
I'm currently developing on my local pc, to which I have complete access of course.
However to my production server I have only FTP access.
Now, this step
http://www.symfony-project.org/getting-started/1_4/en/05-Web-Server-Configuration
On Symfony's installation guide, suggests that I need to edit the httpd.conf
I was wondering if there's an alternative since I don't have access to it on production.
Try reading this. I haven't tried installing Symfony on a shared host, but I see no reason for it not to work.
Generally shared hosts allow you to set configuration parameters in .htaccess files, so you can override httpd.conf without modifying it.