Nginx-ru mailing list archive (nginx-ru@sysoev.ru)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Apache nginx доступ по ип и домену
- To: nginx-ru@xxxxxxxxx
- Subject: Apache nginx доступ по ип и домену
- From: "UserQ" <nginx-forum@xxxxxxxx>
- Date: Thu, 13 Dec 2012 15:02:09 -0500
- Dkim-signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tigger.jlkhosting.com; s=x; h=Date:Sender:From:Message-ID:Content-Transfer-Encoding:Content-Type:Subject:To; bh=en6GbS26/xuF8/3JZa8RNbq11Dv1HdV4m/weNvC7sZU=; b=ha9tUXV1X6+YAjMwagybvqo6MuEkhOHlTLlk7rbEAWyy2ZYSUoqvHC1tUc7zT6it+0bSkh5qVkjA6r6drlR3I8czmaG1V0CQhIzNWdSffyHn2yJkFdnZh3kX/6d0oKmp;
В общем задача такого плана стоит подружить nginx and Apache. А именно
необходимо заставить работать корректно IP и домены. Сейчас проблема состоит
в том что когда подключается IP домены не хотят себя корректно вести, те они
только доступны как указано в конфиге на ип.
Конфиги
Самого nginx
cat /etc/nginx/nginx.conf
user www-data;
worker_processes 4;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/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 /var/log/nginx/access.log main;
## Proxy
proxy_redirect off;
proxy_set_header Host $host;
#proxy_set_header X-Real-IP $remote_addr;
set_real_ip_from 0.0.0.0/0;
real_ip_header Real-IP;
real_ip_recursive on;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffers 8 16k;
proxy_buffer_size 32k;
## Compression
gzip on;
gzip_types text/plain text/css application/x-javascript
text/xml application/xml
application/xml+rss text/javascript;
gzip_disable "MSIE [1-6].(?!.*SV1)";
### TCP options
tcp_nodelay on;
tcp_nopush on;
keepalive_timeout 10;
sendfile on;
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
nginx на ип адрес
Код: Выделить всё
cat /etc/nginx/sites-enabled/ip
server {
listen 80;
server_name 1.1.1.1;
access_log /var/log/nginx.access_log;
location ~*
.(jpg|jpeg|gif|png|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|tar|wav|bmp|rtf|swf|ico|flv|txt|xml|docx|xlsx)$
{
root /var/www/html/;
index index.html index.php;
access_log off;
expires 30d;
}
location ~ /.ht {
deny all;
}
location / {
proxy_pass http://127.0.0.1:81/;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-for $remote_addr;
proxy_set_header Host $host;
proxy_connect_timeout 60;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_redirect off;
proxy_set_header Connection close;
proxy_pass_header Content-Type;
proxy_pass_header Content-Disposition;
proxy_pass_header Content-Length;
}
}
nginx на домен
Код: Выделить всё
cat /etc/nginx/sites-enabled/domain
server {
root /var/www/domain;
index index.html index.htm index.php;
server_name domain.com;
location ~*
.(jpg|jpeg|gif|png|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|tar|wav|bmp|rtf|swf|ico|flv|txt|xml|docx|xlsx)$
{
root /var/www/domain/;
index index.html index.php;
access_log off;
expires 30d;
}
location ~ /.ht {
deny all;
}
location / {
proxy_pass http://127.0.0.1:81/;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-for $remote_addr;
proxy_set_header Host $host;
proxy_connect_timeout 60;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_redirect off;
proxy_set_header Connection close;
proxy_pass_header Content-Type;
proxy_pass_header Content-Disposition;
proxy_pass_header Content-Length;
}
}
на apache
Код: Выделить всё
cat /etc/apache2/httpd.conf
ServerName *
apache на ип
Код: Выделить всё
cat /etc/apache2/sites-enabled/000-default
<VirtualHost *:81>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error,
crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
apache на домен
Код: Выделить всё
cat /etc/apache2/sites-enabled/domain
<VirtualHost *:81>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/domain
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error,
crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Код: Выделить всё
cat /etc/apache2/ports.conf
NameVirtualHost *:81
Listen 81
<IfModule mod_ssl.c>
Listen 443
</IfModule>
<IfModule mod_gnutls.c>
Listen 443
</IfModule>
Спасибо
PS Надеюсь корректно выразился по поводу моей проблемы. Те заходим по ип
1.1.1.1 показывает всё с директории /var/www/html заходи по домену(ам)
/var/www/domain
PS Стоял чистый nginx +php-fpm работало как надо. Но надо проверить
несколько аспектов как будет работать в такой связке.
Posted at Nginx Forum:
http://forum.nginx.org/read.php?21,233986,233986#msg-233986
_______________________________________________
nginx-ru mailing list
nginx-ru@xxxxxxxxx
http://mailman.nginx.org/mailman/listinfo/nginx-ru
|