Welcome! Log In Create A New Profile

Advanced

Apache nginx доступ по ип и домену

December 13, 2012 03:02PM
В общем задача такого плана стоит подружить 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 работало как надо. Но надо проверить несколько аспектов как будет работать в такой связке.
Subject Author Posted

Apache nginx доступ по ип и домену

UserQ December 13, 2012 03:02PM

Re: Apache nginx доступ по ип и домену

Andrey Repin December 13, 2012 11:22PM

Re: Apache nginx доступ по ип и домену

Pavel V. December 13, 2012 11:28PM

Re: Apache nginx доступ по ип и домену

Andrey Repin December 14, 2012 06:52PM

Re: Apache nginx доступ по ип и домену

Pavel V. December 15, 2012 03:26AM

Re: Apache nginx доступ по ип и домену

Andrey Repin December 15, 2012 03:22PM

Re: Apache nginx доступ по ип и домену

Andrey Kopeyko December 14, 2012 02:10AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

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