Welcome! Log In Create A New Profile

Advanced

Re: Location served by all virtual servers

Styopa Semenukha
January 05, 2015 01:48PM
On Monday, January 05, 2015 01:11:08 PM blu wrote:
> Hi, I have some configuration issue with my nginx. Currently both URLs
> return the same page when I open:
> http://domain1.com/SharedFIles and http://domain2.com/SharedFiles.
>
> Location "SharedFiles" is definied only in one virtual server (domain2)
> however it is accessible from both domains. How come?
> I'd like to have it only in a way that only domain2.com serves SharedFiles
> location.
>
> What's wrong? THank you!
>
>
> Here are two config files (doamin1 and domain2) I have in sites-available:
>
> file domain1:
> server {
> listen 80; ## listen for ipv4; this line is default and implied
> root /home/pi/webapps/domain1/public_html;
> index index.html index.htm;
> server_name *.domain1.com;
> }
>
> file domain2:
> server {
> listen 80;
> server_name *.domain2.com;
>
> access_log /home/pi/webapps/domain2/logs/nginx-access.log;
> error_log /home/pi/webapps/domain2/logs/nginx-error.log;
>
> location /SharedFiles {
> root /media/Seagate/Video;
> auth_basic "Restricted";
> auth_basic_user_file /etc/nginx/.htpasswd;
> autoindex on;
> }
> }

The hostname "domain1.com" is NOT matched by wildcard "*.domain1.com" (this
only matches subdomains), so it gets served by the default virtual host. Since
you don't have an explicit definiton of the default vhost, it's the first one
(most likely, alphabetically). In your case, the default one is
"*.domain2.com".

Solution: add "domain1.com" and "domain2.com" server names to your config.
--
Best regards,
Styopa Semenukha.

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Location served by all virtual servers

blu January 05, 2015 01:11PM

Re: Location served by all virtual servers

Styopa Semenukha January 05, 2015 01:48PM

Re: Location served by all virtual servers

Edho Arief January 05, 2015 01:52PM

Re: Location served by all virtual servers

blu January 06, 2015 08:34AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 256
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready