Apache nginx доступ по ип и домену
Добавлено: 2012-12-13 21:11:58
В общем задача такого плана стоит подружить nginx and Apache. А именно необходимо заставить работать корректно IP и домены. Сейчас проблема состоит в том что когда подключается IP домены не хотят себя корректно вести, те они только доступны как указано в конфиге на ип.
Конфиги
Самого nginx
nginx на ип адрес
nginx на домен
на apache
apache на ип
apache на домен
Спасибо
PS Надеюсь корректно выразился по поводу моей проблемы. Те заходим по ип 1.1.1.1 показывает всё с директории /var/www/html заходи по домену(ам) /var/www/domain
Конфиги
Самого 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/*;
}
Код: Выделить всё
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;
}
}
Код: Выделить всё
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;
}
}
Код: Выделить всё
cat /etc/apache2/httpd.conf
ServerName *
Код: Выделить всё
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>
Код: Выделить всё
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