apache 2 + nginx

Обсуждение настройки и работы сервисов, резервирования, сетевых настроек и вопросов безопасности ОС для молодых и начинающих системных администраторов.

Модераторы: SLEDopit, Модераторы разделов

Denikin
Сообщения: 119

apache 2 + nginx

Сообщение Denikin »

Все настроил по дефолту, работает.
апач висит на локалхосте
Проблема в доступе к директориям phpmyadmin, mail (squirrel), webalizer
те эти продукты находятся в директории моего дефолтного сайта
но доступны они теперь только через локалхост, те.
127.0.0.1/phpmyadmin - работает
my_IP/phpmyadmin - не работает

Привожу конфиги
nginx.conf

Код: Выделить всё

user  nobody;
worker_processes  1;

error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    gzip  on;

    server {
        listen       192.168.128.21:80;
        server_name  suse.network.local;

        #charset koi8-r;

        access_log  logs/suse.network.local.access.log  main;

        location / {
             root   /srv/www/htdocs;
            index  index.html index.htm;

#            proxy_pass   http://127.0.0.1;     #Apache у нас на 80 порту, поэтому достаточно указать адрес.
    }
#Установка необходимых заголовков, для передачи Apache имени виртуального хоста и реального IP адреса клиента
            proxy_set_header Host $host;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

         location ~* \.(jpg|jpeg|gif|png|ico) {    #В данной секции используется регулярное выражение, под которое подпадают все файлы, с перечисленными расширениями, как видите это картинки. Nginx будет сам обрабатывать запросы попадающие в этот блок.
            root   /srv/www/htdocs;    #Корень дерева документов для данного Location.
        }

      #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   /srv/www/htdocs;
        }

        #proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        location ~ \.php$ {
            proxy_pass   http://127.0.0.1;
        root    /srv/www/htdocs/;
        }

     location ~ \.php$ {
            proxy_pass   http://127.0.0.1;
        root    /srv/www/htdocs/phpMyAdmin;
        }

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        location ~ /\.ht {
            deny  all;
        }
    }


    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}


    # HTTPS server
    #
    #server {
    #    listen       443;
    #    server_name  localhost;

    #    ssl                  on;
    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_timeout  5m;

    #    ssl_protocols  SSLv2 SSLv3 TLSv1;
    #    ssl_ciphers  ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
    #    ssl_prefer_server_ciphers   on;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}

}


apache
default-server.conf

Код: Выделить всё

#
# Global configuration that will be applicable for all virtual hosts, unless
# deleted here, or overriden elswhere.
#

DocumentRoot "/srv/www/htdocs"

#
# Configure the DocumentRoot
#
<Directory "/srv/www/htdocs">
       # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs-2.2/mod/core.html#options
    # for more information.
Options +Indexes FollowSymLinks
       # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   Options FileInfo AuthConfig Limit
AllowOverride None
       # Controls who can get stuff from this server.
Order allow,deny
 Allow from all
</Directory>

# Aliases: aliases can be added as needed (with no limit). The format is
# Alias fakename realname
#
# Note that if you include a trailing / on fakename then the server will
# require it to be present in the URL.  So "/icons" isn't aliased in this
# example, only "/icons/".  If the fakename is slash-terminated, then the
# realname must also be slash terminated, and if the fakename omits the
# trailing slash, the realname must also omit it.
#
# We include the /icons/ alias for FancyIndexed directory listings.  If you
# do not use FancyIndexing, you may comment this out.
#
Alias /icons/ "/usr/share/apache2/icons/"

<Directory "/usr/share/apache2/icons">
 Options Indexes MultiViews
 AllowOverride None
 Order allow,deny
 Allow from all
</Directory>

#Alias /htdocs2 "/srv/www/htdocs2"
#Alias /htdocs3 "/srv/www/htdocs3"

#Redirect /htdocs2 /htdocs3

#<Directory "/srv/www/htdocs2">
#    Options Indexes MultiViews
#    AllowOverride None
#    Order allow,deny
#    Allow from all
#</Directory>

# ScriptAlias: This controls which directories contain server scripts.
# ScriptAliases are essentially the same as Aliases, except that
# documents in the realname directory are treated as applications and
# run by the server when requested rather than as documents sent to the client.
# The same rules about trailing "/" apply to ScriptAlias directives as to
# Alias.
#
ScriptAlias /cgi-bin/ "/srv/www/htdocs/cgi-bin/"

# "/srv/www/cgi-bin" should be changed to whatever your ScriptAliased
# CGI directory exists, if you have that configured.
#
<Directory "/srv/www/htdocs/cgi-bin">
 AllowOverride None
 Options +ExecCGI -Includes
 Order allow,deny
 Allow from all
</Directory>

# UserDir: The name of the directory that is appended onto a user's home
# directory if a ~user request is received.
#
# To disable it, simply remove userdir from the list of modules in APACHE_MODULES
# in /etc/sysconfig/apache2.
#
<IfModule mod_userdir.c>
       # Note that the name of the user directory ("public_html") cannot simply be
    # changed here, since it is a compile time setting. The apache package
    # would have to be rebuilt. You could work around by deleting
    # /usr/sbin/suexec, but then all scripts from the directories would be
    # executed with the UID of the webserver.
UserDir public_html
       # The actual configuration of the directory is in
    # /etc/apache2/mod_userdir.conf.
Include /etc/apache2/mod_userdir.conf
</IfModule>


# Include all *.conf files from /etc/apache2/conf.d/.
#
# This is mostly meant as a place for other RPM packages to drop in their
# configuration snippet.
#
# You can comment this out here if you want those bits include only in a
# certain virtual host, but not here.
#
Include /etc/apache2/conf.d/*.conf

# The manual... if it is installed ('?' means it won't complain)
Include /etc/apache2/conf.d/apache2-manual?conf
ServerName suse.network.local

ServerAdmin root@suse.network.local

#restrict access to webalizer page
#by Den 14112009
<Location /webalizer>
AuthType Basic
AuthName "Restricted"
AuthUserFile /etc/apache2/webalizer_passwd
Require valid-user
</Location>


listen.conf

Код: Выделить всё

Listen 127.0.0.1:80
<IfDefine SSL>
    <IfDefine !NOSSL>
    <IfModule mod_ssl.c>

        Listen 443

    </IfModule>
    </IfDefine>
</IfDefine>
Спасибо сказали:
Kreept
Сообщения: 107
ОС: Linux

Re: apache 2 + nginx

Сообщение Kreept »

Что пишет нгикс в лог при обращении my_IP/phpmyadmin ?
Папка phpmyadmin находится в директории /srv/www/htdocs ?
Спасибо сказали:
Denikin
Сообщения: 119

Re: apache 2 + nginx

Сообщение Denikin »

Kreept писал(а):
27.11.2009 14:19
Что пишет нгикс в лог при обращении my_IP/phpmyadmin ?

192.168.128.21 - - [27/Nov/2009:19:07:00 +0600] "GET /phpmyadmin HTTP/1.1" 301 185 "-" "Mozilla/5.0 (compatible; Konqueror/4.1; Linux) KHTML/4.1.3 (like Gecko) SUSE" "-"
Папка phpmyadmin находится в директории /srv/www/htdocs ?

да

те возвращает код 301
301 Moved Permanently (Перемещёно окончательно)
Появился в HTTP/1.0.
Запрошенный документ был окончательно перенесен на новый URI, указанный в поле Location заголовка. Учтите что некоторые клиенты некорректно ведут себя при обработке данного кода (см. описание ко всему классу 3xx).
Спасибо сказали:
Kreept
Сообщения: 107
ОС: Linux

Re: apache 2 + nginx

Сообщение Kreept »

Код: Выделить всё

        location ~ \.php$ {
            proxy_pass   http://127.0.0.1;
        root    /srv/www/htdocs/;
        }

     location ~ \.php$ {
            proxy_pass   http://127.0.0.1;
        root    /srv/www/htdocs/phpMyAdmin;
        }


Стоит второй location убрать, насколько я понял папка у Вас имеет вид /srv/www/htdocs/phpMyAdmin, а Вы обращаетесь к my_IP/phpmyadmin, попробуйте my_IP/phpMyAdmin. Если проблема останется, то выложите error_log
Спасибо сказали:
Denikin
Сообщения: 119

Re: apache 2 + nginx

Сообщение Denikin »

Kreept писал(а):
27.11.2009 17:05

Код: Выделить всё

        location ~ \.php$ {
            proxy_pass   http://127.0.0.1;
        root    /srv/www/htdocs/;
        }

     location ~ \.php$ {
            proxy_pass   http://127.0.0.1;
        root    /srv/www/htdocs/phpMyAdmin;
        }


Стоит второй location убрать, насколько я понял папка у Вас имеет вид /srv/www/htdocs/phpMyAdmin, а Вы обращаетесь к my_IP/phpmyadmin, попробуйте my_IP/phpMyAdmin. Если проблема останется, то выложите error_log

Этот второй локейшн я уже добавил после, думал может поможет, ан нет, не помогло. Так что, что с ним, что без него - не работает. На счет phpmyadmin - phpMyAdmin, там у меня алиас стоит, но тоже не то, потому что /mail , /webalizer тоже не работают.
Спасибо сказали:
Kreept
Сообщения: 107
ОС: Linux

Re: apache 2 + nginx

Сообщение Kreept »

Покажите error_log nginx.
Спасибо сказали:
Denikin
Сообщения: 119

Re: apache 2 + nginx

Сообщение Denikin »

Kreept писал(а):
27.11.2009 20:06
Покажите error_log nginx.

Код: Выделить всё

2009/11/26 18:23:57 [emerg] 11183#0: unexpected "}" in /usr/local/nginx/conf/nginx.conf:71
2009/11/26 18:58:27 [emerg] 11737#0: bind() to 192.168.128.21:80 failed (98: Address already in use)
2009/11/26 18:58:27 [emerg] 11737#0: bind() to 192.168.128.21:80 failed (98: Address already in use)
2009/11/26 18:58:27 [emerg] 11737#0: bind() to 192.168.128.21:80 failed (98: Address already in use)
2009/11/26 18:58:27 [emerg] 11737#0: bind() to 192.168.128.21:80 failed (98: Address already in use)
2009/11/26 18:58:27 [emerg] 11737#0: bind() to 192.168.128.21:80 failed (98: Address already in use)
2009/11/26 18:58:27 [emerg] 11737#0: still could not bind()
2009/11/27 16:31:02 [emerg] 1615#0: bind() to 192.168.128.21:80 failed (99: Cannot assign requested address)
2009/11/27 18:58:10 [emerg] 1613#0: bind() to 192.168.128.21:80 failed (99: Cannot assign requested address)
2009/11/27 19:06:57 [error] 3666#0: *2 open() "/srv/www/htdocs/favicon.ico" failed (2: No such file or directory), client: 192.168.128.21, server: suse.network.local, request: "GET /favicon.ico HTTP/1.1", host: "192.168.128.21"
2009/12/01 19:45:41 [error] 3646#0: *2 open() "/srv/www/htdocs/favicon.ico" failed (2: No such file or directory), client: 192.168.128.21, server: suse.network.local, request: "GET /favicon.ico HTTP/1.1", host: "192.168.128.21"
Спасибо сказали:
Kreept
Сообщения: 107
ОС: Linux

Re: apache 2 + nginx

Сообщение Kreept »

Проверьте или точно nginx слушает 192.168.128.21:80 (команда HEAD). Если просто в браузере набираете 192.168.128.21, все корректно отображается?
Спасибо сказали: