nginx subsite configuration not working

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

nginx subsite configuration not working

Kaushal Shriyan
Hi,

I am running nginx version: nginx/1.16.1 on CentOS Linux release 7.8.2003 (Core). I am setting up the Nginx subsite configuration. The details are as follows.

[root@developerportal www]# pwd
/var/www
[root@developerportal www]# ls -l
total 0
drwxr-xr-x 2 root  root   6 Apr  2 18:44 cgi-bin
drwxr-xr-x 3 nginx nginx 64 Jun 10 13:52 drupal
drwxr-xr-x 3 nginx nginx 28 Aug  1 12:32 drupalsubsite
drwxr-xr-x 2 root  root   6 Apr  2 18:44 html
[root@developerportal www]#
[root@developerportal web]# pwd
/var/www/drupal/marketplace-v2/mpV2/web
[root@developerportal web]# ls -l
total 73576
-rwxr-xr-x  1 nginx nginx      385 Jul 28 18:25 autoload.php
drwxrwxrwx 12 nginx nginx     4096 Jun 11 14:21 core
-rw-r--r--  1 nginx nginx 75310608 Aug  1 11:18 db.sql
-rwxr-xr-x  1 nginx nginx      549 Jul 26 18:47 index.php
drwxrwxrwx 14 nginx nginx      286 Jul 28 18:25 libraries
drwxrwxrwx  6 nginx nginx      101 Jul 26 18:47 modules
drwxrwxrwx  2 nginx nginx       22 Jul 26 18:47 profiles
lrwxrwxrwx  1 nginx nginx       47 Aug  1 16:23 retail -> /var/www/drupalsubsite/marketplace-v2/mpV2/web/
-rwxr-xr-x  1 nginx nginx     1594 Jul 26 18:47 robots.txt
drwxrwxrwx  3 nginx nginx      112 Jul 26 18:47 sites
drwxrwxrwx  4 nginx nginx       69 Jul 26 18:47 themes
-rwxr-xr-x  1 nginx nginx      848 Jul 26 18:47 update.php
-rwxr-xr-x  1 nginx nginx     4566 Jul 26 18:47 web.config
[root@developerportal web]#

I have set the below in /etc/nginx/nginx.conf

location ~ ^/retail/(.*) {
    return 301 /var/www/drupalsubsite/marketplace-v2/mpV2/web;
   index index.php;
}

I get https://developerportal.example.com/var/www/drupalsubsite/marketplace-v2/mpV2/web in the browser I get  The requested page could not be found instead of serving the web page.

I get https://developerportal.example.com/var/www/drupalsubsite/marketplace-v2/mpV2/web in the browser I get  The requested page could not be found instead of serving the web page.

I get https://developerportal.example.com/var/www/drupalsubsite/marketplace-v2/mpV2/web in the browser I get  The requested page could not be found instead of serving the web page.

Any help will be highly appreciated. Please let me know if you need any additional configuration and I look forward to hearing from you soon.
Thanks in advance.

Best Regards,

Kaushal


_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: nginx subsite configuration not working

Thomas Ward
301 Redirects don't work for full system paths because they are returned to the client saying "go here instead".  It then interprets your path as a URI which doesn't exist inside your site docroot.

You might have meant to use `root` instead of `return 301` here to serve the data directly from that directory at the path you are accessing it from on the client browser.

From: Kaushal Shriyan
Sent: Sat Aug 01 13:09:17 EDT 2020
To: [hidden email]
Subject: nginx subsite configuration not working

Hi,

I am running nginx version: nginx/1.16.1 on CentOS Linux release 7.8.2003 (Core). I am setting up the Nginx subsite configuration. The details are as follows.

[root@developerportal www]# pwd
/var/www
[root@developerportal www]# ls -l
total 0
drwxr-xr-x 2 root  root   6 Apr  2 18:44 cgi-bin
drwxr-xr-x 3 nginx nginx 64 Jun 10 13:52 drupal
drwxr-xr-x 3 nginx nginx 28 Aug  1 12:32 drupalsubsite
drwxr-xr-x 2 root  root   6 Apr  2 18:44 html
[root@developerportal www]#
[root@developerportal web]# pwd
/var/www/drupal/marketplace-v2/mpV2/web
[root@developerportal web]# ls -l
total 73576
-rwxr-xr-x  1 nginx nginx      385 Jul 28 18:25 autoload.php
drwxrwxrwx 12 nginx nginx     4096 Jun 11 14:21 core
-rw-r--r--  1 nginx nginx 75310608 Aug  1 11:18 db.sql
-rwxr-xr-x  1 nginx nginx      549 Jul 26 18:47 index.php
drwxrwxrwx 14 nginx nginx      286 Jul 28 18:25 libraries
drwxrwxrwx  6 nginx nginx      101 Jul 26 18:47 modules
drwxrwxrwx  2 nginx nginx       22 Jul 26 18:47 profiles
lrwxrwxrwx  1 nginx nginx       47 Aug  1 16:23 retail -> /var/www/drupalsubsite/marketplace-v2/mpV2/web/
-rwxr-xr-x  1 nginx nginx     1594 Jul 26 18:47 robots.txt
drwxrwxrwx  3 nginx nginx      112 Jul 26 18:47 sites
drwxrwxrwx  4 nginx nginx       69 Jul 26 18:47 themes
-rwxr-xr-x  1 nginx nginx      848 Jul 26 18:47 update.php
-rwxr-xr-x  1 nginx nginx     4566 Jul 26 18:47 web.config
[root@developerportal web]#

I have set the below in /etc/nginx/nginx.conf

location ~ ^/retail/(.*) {
    return 301 /var/www/drupalsubsite/marketplace-v2/mpV2/web;
   index index.php;
}

I get https://developerportal.example.com/var/www/drupalsubsite/marketplace-v2/mpV2/web in the browser I get  The requested page could not be found instead of serving the web page.

I get https://developerportal.example.com/var/www/drupalsubsite/marketplace-v2/mpV2/web in the browser I get  The requested page could not be found instead of serving the web page.

I get https://developerportal.example.com/var/www/drupalsubsite/marketplace-v2/mpV2/web in the browser I get  The requested page could not be found instead of serving the web page.

Any help will be highly appreciated. Please let me know if you need any additional configuration and I look forward to hearing from you soon.
Thanks in advance.

Best Regards,

Kaushal



nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: nginx subsite configuration not working

Kaushal Shriyan


On Sat, Aug 1, 2020 at 10:42 PM Thomas Ward <[hidden email]> wrote:
301 Redirects don't work for full system paths because they are returned to the client saying "go here instead".  It then interprets your path as a URI which doesn't exist inside your site docroot.

You might have meant to use `root` instead of `return 301` here to serve the data directly from that directory at the path you are accessing it from on the client browser.

Hi Thomas

Thanks for the reply. I have set it to below.

location /retail {
     root /var/www/drupalsubsite/marketplace-v2/mpV2/web; 
   #root /var/www/drupal/marketplace-v2/mpV2/web;
    index index.php;
}

retail is a soft link inside /var/www/drupal/marketplace-v2/mpV2/web directory pointing to /var/www/drupalsubsite/marketplace-v2/mpV2/web directory

[root@developerportal www]# pwd
/var/www
[root@developerportal www]# ls -l
total 0
drwxr-xr-x 2 root  root   6 Apr  2 18:44 cgi-bin
drwxr-xr-x 3 nginx nginx 64 Jun 10 13:52 drupal
drwxr-xr-x 3 nginx nginx 28 Aug  1 12:32 drupalsubsite
drwxr-xr-x 2 root  root   6 Apr  2 18:44 html
[root@developerportal www]#
[root@developerportal web]# pwd
/var/www/drupal/marketplace-v2/mpV2/web
[root@developerportal web]# ls -l
total 73576
-rwxr-xr-x  1 nginx nginx      385 Jul 28 18:25 autoload.php
drwxrwxrwx 12 nginx nginx     4096 Jun 11 14:21 core
-rw-r--r--  1 nginx nginx 75310608 Aug  1 11:18 db.sql
-rwxr-xr-x  1 nginx nginx      549 Jul 26 18:47 index.php
drwxrwxrwx 14 nginx nginx      286 Jul 28 18:25 libraries
drwxrwxrwx  6 nginx nginx      101 Jul 26 18:47 modules
drwxrwxrwx  2 nginx nginx       22 Jul 26 18:47 profiles
lrwxrwxrwx  1 nginx nginx       47 Aug  1 16:23 retail -> /var/www/drupalsubsite/marketplace-v2/mpV2/web/
-rwxr-xr-x  1 nginx nginx     1594 Jul 26 18:47 robots.txt
drwxrwxrwx  3 nginx nginx      112 Jul 26 18:47 sites
drwxrwxrwx  4 nginx nginx       69 Jul 26 18:47 themes
-rwxr-xr-x  1 nginx nginx      848 Jul 26 18:47 update.php
-rwxr-xr-x  1 nginx nginx     4566 Jul 26 18:47 web.config
[root@developerportal web]#


2020/08/02 05:12:29 [error] 3429#0: *1 "/var/www/drupalsubsite/marketplace-v2/mpV2/web/retail/index.php" is not found (2: No such file or directory), client: 192.168.0.10, server: developerportal.example.com, request: "GET /retail/ HTTP/1.1", host: "developerportal.example.com"

==> /var/log/nginx/access.log <==
192.168.0.10 - [02/Aug/2020:05:12:29 +0530] "GET /retail/ HTTP/1.1" 404 153 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:79.0) Gecko/20100101 Firefox/79.0" "-"

2020/08/02 05:11:46 [error] 3429#0: *1 open() "/var/www/drupalsubsite/marketplace-v2/mpV2/web/retail/user" failed (2: No such file or directory), client: 192.168.0.10, server: developerportal.example.com, request: "GET /retail/user HTTP/1.1", host: "developerportal.example.com"

==> /var/log/nginx/access.log <==
192.168.0.10 - [02/Aug/2020:05:11:46 +0530] "GET /retail/user HTTP/1.1" 404 153 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:79.0) Gecko/20100101 Firefox/79.0" "-"

==> /var/log/nginx/error.log <==
2020/08/02 05:11:50 [error] 3429#0: *1 open() "/var/www/drupalsubsite/marketplace-v2/mpV2/web/retail/user/login" failed (2: No such file or directory), client: 192.168.0.10, server: developerportal.example.com, request: "GET /retail/user/login HTTP/1.1", host: "developerportal.example.com"

==> /var/log/nginx/access.log <==
192.168.0.10 - [02/Aug/2020:05:11:50 +0530] "GET /retail/user/login HTTP/1.1" 404 153 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:79.0) Gecko/20100101 Firefox/79.0" "-"

Any help will be highly appreciated. Please let me know if you need any additional configuration and I look forward to hearing from you soon.

Thanks in advance.

Best Regards,

Kaushal


_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: nginx subsite configuration not working

Kaushal Shriyan


On Sun, Aug 2, 2020 at 5:18 AM Kaushal Shriyan <[hidden email]> wrote:


On Sat, Aug 1, 2020 at 10:42 PM Thomas Ward <[hidden email]> wrote:
301 Redirects don't work for full system paths because they are returned to the client saying "go here instead".  It then interprets your path as a URI which doesn't exist inside your site docroot.

You might have meant to use `root` instead of `return 301` here to serve the data directly from that directory at the path you are accessing it from on the client browser.

Hi Thomas

Thanks for the reply. I have set it to below.

location /retail {
     root /var/www/drupalsubsite/marketplace-v2/mpV2/web; 
   #root /var/www/drupal/marketplace-v2/mpV2/web;
    index index.php;
}

retail is a soft link inside /var/www/drupal/marketplace-v2/mpV2/web directory pointing to /var/www/drupalsubsite/marketplace-v2/mpV2/web directory

[root@developerportal www]# pwd
/var/www
[root@developerportal www]# ls -l
total 0
drwxr-xr-x 2 root  root   6 Apr  2 18:44 cgi-bin
drwxr-xr-x 3 nginx nginx 64 Jun 10 13:52 drupal
drwxr-xr-x 3 nginx nginx 28 Aug  1 12:32 drupalsubsite
drwxr-xr-x 2 root  root   6 Apr  2 18:44 html
[root@developerportal www]#
[root@developerportal web]# pwd
/var/www/drupal/marketplace-v2/mpV2/web
[root@developerportal web]# ls -l
total 73576
-rwxr-xr-x  1 nginx nginx      385 Jul 28 18:25 autoload.php
drwxrwxrwx 12 nginx nginx     4096 Jun 11 14:21 core
-rw-r--r--  1 nginx nginx 75310608 Aug  1 11:18 db.sql
-rwxr-xr-x  1 nginx nginx      549 Jul 26 18:47 index.php
drwxrwxrwx 14 nginx nginx      286 Jul 28 18:25 libraries
drwxrwxrwx  6 nginx nginx      101 Jul 26 18:47 modules
drwxrwxrwx  2 nginx nginx       22 Jul 26 18:47 profiles
lrwxrwxrwx  1 nginx nginx       47 Aug  1 16:23 retail -> /var/www/drupalsubsite/marketplace-v2/mpV2/web/
-rwxr-xr-x  1 nginx nginx     1594 Jul 26 18:47 robots.txt
drwxrwxrwx  3 nginx nginx      112 Jul 26 18:47 sites
drwxrwxrwx  4 nginx nginx       69 Jul 26 18:47 themes
-rwxr-xr-x  1 nginx nginx      848 Jul 26 18:47 update.php
-rwxr-xr-x  1 nginx nginx     4566 Jul 26 18:47 web.config
[root@developerportal web]#


2020/08/02 05:12:29 [error] 3429#0: *1 "/var/www/drupalsubsite/marketplace-v2/mpV2/web/retail/index.php" is not found (2: No such file or directory), client: 192.168.0.10, server: developerportal.example.com, request: "GET /retail/ HTTP/1.1", host: "developerportal.example.com"

==> /var/log/nginx/access.log <==
192.168.0.10 - [02/Aug/2020:05:12:29 +0530] "GET /retail/ HTTP/1.1" 404 153 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:79.0) Gecko/20100101 Firefox/79.0" "-"

2020/08/02 05:11:46 [error] 3429#0: *1 open() "/var/www/drupalsubsite/marketplace-v2/mpV2/web/retail/user" failed (2: No such file or directory), client: 192.168.0.10, server: developerportal.example.com, request: "GET /retail/user HTTP/1.1", host: "developerportal.example.com"

==> /var/log/nginx/access.log <==
192.168.0.10 - [02/Aug/2020:05:11:46 +0530] "GET /retail/user HTTP/1.1" 404 153 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:79.0) Gecko/20100101 Firefox/79.0" "-"

==> /var/log/nginx/error.log <==
2020/08/02 05:11:50 [error] 3429#0: *1 open() "/var/www/drupalsubsite/marketplace-v2/mpV2/web/retail/user/login" failed (2: No such file or directory), client: 192.168.0.10, server: developerportal.example.com, request: "GET /retail/user/login HTTP/1.1", host: "developerportal.example.com"

==> /var/log/nginx/access.log <==
192.168.0.10 - [02/Aug/2020:05:11:50 +0530] "GET /retail/user/login HTTP/1.1" 404 153 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:79.0) Gecko/20100101 Firefox/79.0" "-"

Any help will be highly appreciated. Please let me know if you need any additional configuration and I look forward to hearing from you soon.

Thanks in advance.

Best Regards,

Kaushal


Hi,

When I hit https://developer.example.com/retail on the browser it should render web pages from /var/www/drupalsubsite/marketplace-v2/mpV2/web directory. I tried the below options in /etc/nginx/nginx.conf and none of the options work.

Option 1)

rewrite ^/$ /var/www/drupalsubsite/marketplace-v2/mpV2/web;

Option 2)

location /retail {
root /var/www/drupalsubsite/marketplace-v2/mpV2/web;
# root /var/www/drupal/marketplace-v2/mpV2/web;
index index.php;
}

Option 3)

location /retail {
root /var/www/drupal/marketplace-v2/mpV2/web;
disable_symlinks off;
index index.php;
}

Any help will be highly appreciated. Thanks in Advance. I look forward to hearing from you.

Best Regards,

Kaushal
 

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: nginx subsite configuration not working

Miguel Clara
Looks like it's a Drupal (php) site just pointing it to index.php won't work you need to have a back end for PHP.... I.E. php-fpm and setup nginx to use fastcgi proxy.

The exact config might be different depending on how urls are handled in Drupal, I'm more familiar with WordPress, but I found this that seems to offer great help:


_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: nginx subsite configuration not working

Kaushal Shriyan


On Sun, Aug 2, 2020 at 7:06 PM Miguel C <[hidden email]> wrote:
Looks like it's a Drupal (php) site just pointing it to index.php won't work you need to have a back end for PHP.... I.E. php-fpm and setup nginx to use fastcgi proxy.

The exact config might be different depending on how urls are handled in Drupal, I'm more familiar with WordPress, but I found this that seems to offer great help:

_______________________________________________

Thanks Miguel for the email and much appreciated.


_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx