Welcome! Log In Create A New Profile

Advanced

accessing two different sites by 192.x.x.x/test1 and 192.x.x.x/test2 possible?

Posted by matzepatze 
Hey there,

I spent couple of days to get this running, but did not succeed:

On my raspberry I want to run owncloud and web-service to manage mpd. I set up the owncloud and also the mentioned webservice.

As I am not sure, if this really possible, here is my kind of wish-list:

I would like to access owncloud in my local network by typing 192,x.x.x/cloud to get to the owncloud start page.
With 192.x.x.x/music I would like to get the site of the music-service.

As I spent several days to get this running without success, I would like to ask, if this realisation is possible or not. If it is possible I will decribe my actual set-up of nginx and fpm-php much clearer.

Thanks,
Matthias
Re: accessing two different sites by 192.x.x.x/test1 and 192.x.x.x/test2 possible?
May 03, 2014 02:41PM
Sure, for each named site create a location block;

location /path1 {
root /etc/path1;
.......
}

location /path2 {
root /etc/path2;
.......
}

http://nginx.org/en/docs/http/ngx_http_core_module.html#location

---
nginx for Windows http://nginx-win.ecsds.eu/
Thanks for your reply. Now I know, that was not completely wrong.

I actually defined two site in the "sites-available" folder of nginx: owncloud and rompr


owncloud:

server {
listen 8080;

root /var/www;
access_log /var/log/nginx/access_log_custom1;
#index index.html index.htm index.php;

server_name cloud;
#server_name rompr;


location /cloud {
root /var/www/cloud;
index index.html index.php;
}


location ~ \.php$ {
fastcgi_intercept_errors on;
fastcgi_pass unix:/var/run/php5-fpm-owncloud.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
}


and for rompr:


server {
listen 80;

access_log /var/log/nginx/access_log_www;


server_name rompr;

location /rompr {

root /var/www/rompr;
index index.php;

}


location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm-rompr.sock;
fastcgi_index index.php;
include fastcgi_params;
}

}





The thing is still not working. The error.log tells:

2014/05/04 07:27:32 [crit] 22455#0: *1 connect() to unix:/var/run/php5-fpm-rompr.sock failed (2: No such file or directory) while connecting to upstream, client: 1$
2014/05/04 07:27:39 [error] 22455#0: *1 "/var/www/rompr/rompr/index.php" is not found (2: No such file or directory), client: 192.168.1.37, server: rompr, request:$
2014/05/04 07:27:49 [crit] 22455#0: *1 connect() to unix:/var/run/php5-fpm-rompr.sock failed (2: No such file or directory) while connecting to upstream, client: 1$
2014/05/04 07:33:38 [error] 22455#0: *6 "/var/www/rompr/rompr/index.php" is not found (2: No such file or directory), client: 192.168.1.37, server: rompr, request:$
2014/05/04 07:34:52 [crit] 22455#0: *7 connect() to unix:/var/run/php5-fpm-rompr.sock failed (2: No such file or directory) while connecting to upstream, client: 1$



The first problem is, that the directory path is wrong as "rompr" is doubled. The second problem is, that I type in IP/cloud and IP/rompr but I get the error message for the "rompr" but not for the "cloud". So it seems to me that there is something wrong with linking or redirecting?

Do you have any idea what could be wrong?

Thanks for your help!
Thanks for your reply.

I knew that I was not totally wrong. To give some more details about my configuration:

I defined two sites in the "sites-available" folder of nginx.

Here is the one for owncloud:

server {
listen 8080;

root /var/www;
access_log /var/log/nginx/access_log_custom1;

server_name cloud;


location /cloud {
root /var/www/cloud;
index index.html index.php;
}



location ~ \.php$ {
fastcgi_intercept_errors on;
fastcgi_pass unix:/var/run/php5-fpm-owncloud.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
}

}


and this is the one for rompr:

server {
listen 80;

access_log /var/log/nginx/access_log_www;

server_name rompr;

location /rompr {

root /var/www/rompr;
index index.php;

}


location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm-rompr.sock;
fastcgi_index index.php;
include fastcgi_params;
}

}


If I have a look at the error.log messages:

2014/05/04 07:27:32 [crit] 22455#0: *1 connect() to unix:/var/run/php5-fpm-rompr.sock failed (2: No such file or directory) while connecting to upstream, client: 192.168.1.37, $
2014/05/04 07:27:39 [error] 22455#0: *1 "/var/www/rompr/rompr/index.php" is not found (2: No such file or directory), client: 192.168.1.37, server: rompr, request: "GET /rompr/$
2014/05/04 07:27:49 [crit] 22455#0: *1 connect() to unix:/var/run/php5-fpm-rompr.sock failed (2: No such file or directory) while connecting to upstream, client: 192.168.1.37, $
2014/05/04 07:33:38 [error] 22455#0: *6 "/var/www/rompr/rompr/index.php" is not found (2: No such file or directory), client: 192.168.1.37, server: rompr, request: "GET /rompr/$
2014/05/04 07:34:52 [crit] 22455#0: *7 connect() to unix:/var/run/php5-fpm-rompr.sock failed (2: No such file or directory) while connecting to upstream, client: 192.168.1.37, $


So there seems to be a problem wih the directory because of the doubled "rompr", but also for accessing the "cloud" page since the first two error messages belong to the try for accessing the "cloud"page.

Is there something I could try or to modify in my config-files?

Thanks for help!
Re: accessing two different sites by 192.x.x.x/test1 and 192.x.x.x/test2 possible?
May 04, 2014 07:46AM
Are you sure the sockets are working, rights and so on ?
Not, I'm not sure... :-(

Here is an example for the cloud:

[owncloud]
listen = /var/run/php5-fpm-owncloud.sock
listen.backlog = 4096
user = www-data
group = www-data
pm = dynamic
pm.max_children = 10
pm.start_servers = 3
pm.min_spare_servers = 3
pm.max_spare_servers = 5
pm.max_requests = 40
env[HOSTNAME] = $HOSTNAME
env[PATH] = /usr/local/bin:/usr/bin:/bin
env[TMP] = /tmp
env[TMPDIR] = /tmp
env[TEMP] = /tmp
php_admin_value[open_basedir] = /var/www/cloud/:/tmp/



What else could I check to find the mistake?
Re: accessing two different sites by 192.x.x.x/test1 and 192.x.x.x/test2 possible?
May 04, 2014 09:59AM
It does say "connect() to unix:/var/run/php5-fpm-rompr.sock failed" so I'd google that first.
Ok, thanks. I fixed this by modifing the directory according to the right position.

But now I'm completely lost. I removed the owncloud and tried get "rompr" working.

My only file in "site-available" and "sites-enabled" is "rompr":


server {
listen 80 default_server;

root /var/www/rompr;
index index.php index.html index.htm;
access_log /var/log/nginx/access_log_rompr;
#index index.php index.html index.htm;

server_name localhost;

location /rompr {
#allow all;
#root /var/www/rompr;
index index.php;
#client_max_body_size 32M;

location ~ \.php {
try_files $uri =404;
fastcgi_pass unix:/var/run/php5-fpm-rompr.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $request_filename;
include /etc/nginx/fastcgi_params;
}

error_page 404 = /rompr/404.php;
try_files $uri $uri/ =404;
location ~ /rompr/albumart/* {
expires -1s;
}
}
}



The problem: If it type in IP/rompr I cannot establish a connection and there is nothing in the error.log and the access.log.

Sorry for these kind of stupid questions but there seems to be something going into the wrong direction. Any ideas?
Re: accessing two different sites by 192.x.x.x/test1 and 192.x.x.x/test2 possible?
May 04, 2014 02:09PM
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

---
nginx for Windows http://nginx-win.ecsds.eu/
After setting up nginx and fpm again, the things still do not work. I don't know what's wrong. If I type in the IP of my sever, I get the index.php downloaded. If I use IP/rompr then I get a502 bad gateway.

My default config is:


server {

listen 80 default_server;
#listen [::]:80 default_server ipv6only=on;

root /var/www/rompr;
index index.php index.html index.htm;

# Make site accessible from http://localhost/
server_name localhost;

# This section can be copied into an existing default setup
location /rompr {
allow all;
index index.php;
client_max_body_size 32M;
location ~ \.php$ {
# try_files $uri =404;
# fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
}
error_page 404 = /rompr/404.php;
try_files $uri $uri/ =404;
location ~ /rompr/albumart/* {
expires -1s;
}
}
}


Totally lost :-(
Re: accessing two different sites by 192.x.x.x/test1 and 192.x.x.x/test2 possible?
May 05, 2014 04:45PM
Look at where root is pointing and then look at where php expects stuff to be.

is root and php and $document_root all pointing to the same location? disable all thats not needed like tryfiles, keep a simple config.
Finally it's running. Thanks for your help. My site-file for nginx is at follows:



server {

listen 80 default_server;
#listen [::]:80 default_server ipv6only=on;

root /var/www;
index index.php index.html index.htm;

# Make site accessible from http://localhost/
server_name localhost;

index index.php;

# This section can be copied into an existing default setup
location /rompr {
allow all;
index index.php;
client_max_body_size 32M;
location ~ \.php$ {
# try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm-rompr.sock;
fastcgi_index index.php;
#fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
}
error_page 404 = /rompr/404.php;
try_files $uri $uri/ =404;
location ~ /rompr/albumart/* {
expires -1s;
}
}


location ^~ /cloud {
index index.php;
try_files $uri $uri/ /index.php?$args;
client_max_body_size 512M;
location ~ ^/cloud/(?:\.|data|config|db_structure\.xml|README) {
deny all;
}
rewrite ^/cloud/apps/([^/]+)/(.+\.(css|php))$ /cloud/index.php?app=$1&getfile=$2 last;
rewrite ^/cloud/remote/(.*)$ /cloud/remote.php/$1 last;
location ~ \.php/? {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm-cloud.sock;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~* \.(?:jpg|gif|ico|png|css|js|svg)$ {
expires max; add_header Cache-Control public;
}
}





}
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 172
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