Answer the question
In order to leave comments, you need to log in
Why might the nginx proxy not work?
Good afternoon! We had an owncloud corporate cloud, and it fell in one day! I set a senior task to make nginx on the proxy server and apache on the backend. Found an article , did everything, set it up, everything worked. The authorities were impatient to upload 10G files to the cloud, then apache began to eat resources. There is a task to transfer the backend to nginx made from here . I translated it, but now the problem is that the frontend completely redirects to one of the backend servers, but is not a proxy server. All this miracle works on centos 7, nginx 1.6.3, php-fpm - PHP 5.4.16 (fpm-fcgi). Tell me what I am stupid or what I do not understand. Thank you all in advance.
nginx.conf config on the proxy server:
server {
listen 80;
listen 443 ssl;
server_name 10.0.0.61;
ssl_certificate /etc/nginx/certs/owncloud.crt;
ssl_certificate_key /etc/nginx/certs/owncloud.key;
include /etc/nginx/default.d/*.conf;
if ( $scheme = "http" ) {
rewrite ^/(.*)$ https://$host/$1 permanent;
}
location / {
root /usr/share/nginx/html/;
index index.html;
}
upstream myCloud {
ip_hash;
server 10.0.0.63:80
server 10.0.0.64:80;
}
server {
listen 443 ssl;
server_name 10.0.0.61;
ssl_certificate /etc/nginx/certs/owncloud.crt;
ssl_certificate_key /etc/nginx/certs/owncloud.key;
client_max_body_size 10G; # максимальный файл для загрузки
location / {
proxy_pass http://myCloud;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
server {
listen 80;
server_name 10.0.0.64;
include /etc/nginx/default.d/*.conf;
location / {
root /usr/share/nginx/html/;
index index.html index.htm;
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
upstream php-handler {
server 127.0.0.1:9000;
}
server {
listen 80;
server_name 10.0.0.64;
client_max_body_size 10G; # set max uIpload size
fastcgi_buffers 64 4K;
location = / {
root /usr/share/nginx/html/owncloud/;
index index.php;
rewrite ^/caldav(.*)$ /remote.php/caldav$1 redirect;
rewrite ^/carddav(.*)$ /remote.php/carddav$1 redirect;
rewrite ^/webdav(.*)$ /remote.php/webdav$1 redirect;
error_page 403 /core/templates/403.php;
error_page 404 /core/templates/404.php;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location ~ ^/(data|config|\.ht|db_structure\.xml|README) {
deny all;
}
location / {
rewrite ^/.well-known/host-meta /public.php?service=host-meta last;
rewrite ^/.well-known/host-meta.json /public.php?service=host-meta-json last;
rewrite ^/.well-known/carddav /remote.php/carddav/ redirect;
rewrite ^/.well-known/caldav /remote.php/caldav/ redirect;
rewrite ^(/core/doc/[^\/]+/)$ $1/index.html;
try_files $uri $uri/ index.php;
}
location ~ ^(.+?\.php)(/.*)?$ {
try_files $1 = 404;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$1;
fastcgi_param PATH_INFO $2;
fastcgi_pass php-handler;
}
location ~* ^.+\.(jpg|jpeg|gif|bmp|ico|png|css|js|swf)$ {
expires 30d;
access_log off;
}
}
Answer the question
In order to leave comments, you need to log in
when owcloud + rouncube was integrated due to incorrect proxy settings, the senior said to remove the proxy, leave one server with nginx and php-fpm. Thank you all for your help
Open the phrase
Translated, but now the problem is that the frontend completely redirects to one of the backend servers, but is not a proxy server
You have proxying for all uris in your config:location / {
proxy_pass http://myCloud;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
That is, all requests are proxied to the myCloud upstream. The
blanching inside the upstream goes according to ip_hash, that is, one client will always go to one server.upstream myCloud {
ip_hash;
server 10.0.0.63:80
server 10.0.0.64:80;
}
If this is not the expected behavior, change it.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question