Welcome! Log In Create A New Profile

Advanced

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

Andrey Repin
December 13, 2012 11:22PM
Здравствуйте, Уважаемый(-ая, -ое) UserQ!

U> В общем задача такого плана стоит подружить nginx and Apache. А именно
U> необходимо заставить работать корректно IP и домены. Сейчас проблема состоит
U> в том что когда подключается IP домены не хотят себя корректно вести, те они
U> только доступны как указано в конфиге на ип.

U> Конфиги

U> Самого nginx

А где у вас default сервер определается?
К Апачу этот вопрос тоже относится.

U> cat /etc/nginx/nginx.conf
U> user www-data;
U> worker_processes 4;

U> error_log /var/log/nginx/error.log warn;
U> pid /var/run/nginx.pid;

U> events {
U> worker_connections 1024;
U> }

U> http {
U> include /etc/nginx/mime.types;
U> default_type application/octet-stream;
U> log_format main '$remote_addr - $remote_user [$time_local]
U> "$request" '
U> '$status $body_bytes_sent
U> "$http_referer" '
U> '"$http_user_agent"
U> "$http_x_forwarded_for"';

U> access_log /var/log/nginx/access.log main;

U> ## Proxy
U> proxy_redirect off;
U> proxy_set_header Host $host;
U> #proxy_set_header X-Real-IP $remote_addr;
U> set_real_ip_from 0.0.0.0/0;
U> real_ip_header Real-IP;
U> real_ip_recursive on;
U> proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
U> client_max_body_size 10m;
U> client_body_buffer_size 128k;
U> proxy_connect_timeout 90;
U> proxy_send_timeout 90;
U> proxy_read_timeout 90;
U> proxy_buffers 8 16k;
U> proxy_buffer_size 32k;

U> ## Compression
U> gzip on;
U> gzip_types text/plain text/css application/x-javascript
U> text/xml application/xml
U> application/xml+rss text/javascript;
U> gzip_disable "MSIE [1-6].(?!.*SV1)";

U> ### TCP options
U> tcp_nodelay on;
U> tcp_nopush on;
U> keepalive_timeout 10;
U> sendfile on;

U> include /etc/nginx/conf.d/*.conf;
U> include /etc/nginx/sites-enabled/*;
U> }



U> nginx на ип адрес

U> Код: Выделить всё
U> cat /etc/nginx/sites-enabled/ip
U> server {
U> listen 80;
U> server_name 1.1.1.1;
U> access_log /var/log/nginx.access_log;

U> location ~*
U> .(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)$
U> {
U> root /var/www/html/;
U> index index.html index.php;
U> access_log off;
U> expires 30d;
U> }
U> location ~ /.ht {
U> deny all;
U> }
U> location / {
U> proxy_pass http://127.0.0.1:81/;
U> proxy_set_header X-Real-IP $remote_addr;
U> proxy_set_header X-Forwarded-for $remote_addr;
U> proxy_set_header Host $host;
U> proxy_connect_timeout 60;
U> proxy_send_timeout 90;
U> proxy_read_timeout 90;
U> proxy_redirect off;
U> proxy_set_header Connection close;
U> proxy_pass_header Content-Type;
U> proxy_pass_header Content-Disposition;
U> proxy_pass_header Content-Length;
U> }
U> }



U> nginx на домен

U> Код: Выделить всё
U> cat /etc/nginx/sites-enabled/domain
U> server {

U> root /var/www/domain;
U> index index.html index.htm index.php;

U> server_name domain.com;

U> location ~*
U> .(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)$
U> {
U> root /var/www/domain/;
U> index index.html index.php;
U> access_log off;
U> expires 30d;
U> }
U> location ~ /.ht {
U> deny all;
U> }
U> location / {
U> proxy_pass http://127.0.0.1:81/;
U> proxy_set_header X-Real-IP $remote_addr;
U> proxy_set_header X-Forwarded-for $remote_addr;
U> proxy_set_header Host $host;
U> proxy_connect_timeout 60;
U> proxy_send_timeout 90;
U> proxy_read_timeout 90;
U> proxy_redirect off;
U> proxy_set_header Connection close;
U> proxy_pass_header Content-Type;
U> proxy_pass_header Content-Disposition;
U> proxy_pass_header Content-Length;

U> }
U> }



U> на apache

U> Код: Выделить всё
U> cat /etc/apache2/httpd.conf
U> ServerName *



U> apache на ип

U> Код: Выделить всё
U> cat /etc/apache2/sites-enabled/000-default
U> <VirtualHost *:81>
U> ServerAdmin webmaster@localhost

U> DocumentRoot /var/www/html
U> <Directory />
U> Options FollowSymLinks
U> AllowOverride None
U> </Directory>
U> <Directory /var/www/>
U> Options Indexes FollowSymLinks MultiViews
U> AllowOverride None
U> Order allow,deny
U> allow from all
U> </Directory>

U> ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
U> <Directory "/usr/lib/cgi-bin">
U> AllowOverride None
U> Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
U> Order allow,deny
U> Allow from all
U> </Directory>

U> ErrorLog ${APACHE_LOG_DIR}/error.log

U> # Possible values include: debug, info, notice, warn, error,
U> crit,
U> # alert, emerg.
U> LogLevel warn

U> CustomLog ${APACHE_LOG_DIR}/access.log combined
U> </VirtualHost>



U> apache на домен

U> Код: Выделить всё
U> cat /etc/apache2/sites-enabled/domain
U> <VirtualHost *:81>
U> ServerAdmin webmaster@localhost

U> DocumentRoot /var/www/domain
U> <Directory />
U> Options FollowSymLinks
U> AllowOverride None
U> </Directory>
U> <Directory /var/www/>
U> Options Indexes FollowSymLinks MultiViews
U> AllowOverride None
U> Order allow,deny
U> allow from all
U> </Directory>

U> ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
U> <Directory "/usr/lib/cgi-bin">
U> AllowOverride None
U> Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
U> Order allow,deny
U> Allow from all
U> </Directory>

U> ErrorLog ${APACHE_LOG_DIR}/error.log

U> # Possible values include: debug, info, notice, warn, error,
U> crit,
U> # alert, emerg.
U> LogLevel warn

U> CustomLog ${APACHE_LOG_DIR}/access.log combined
U> </VirtualHost>



U> Код: Выделить всё
U> cat /etc/apache2/ports.conf
U> NameVirtualHost *:81
U> Listen 81

U> <IfModule mod_ssl.c>
U> Listen 443
U> </IfModule>

U> <IfModule mod_gnutls.c>
U> Listen 443
U> </IfModule>



U> Спасибо

U> PS Надеюсь корректно выразился по поводу моей проблемы. Те заходим по ип
U> 1.1.1.1 показывает всё с директории /var/www/html заходи по домену(ам)
U> /var/www/domain

U> PS Стоял чистый nginx +php-fpm работало как надо. Но надо проверить
U> несколько аспектов как будет работать в такой связке.

U> Posted at Nginx Forum: http://forum.nginx.org/read.php?21,233986,233986#msg-233986

U> _______________________________________________
U> nginx-ru mailing list
U> nginx-ru@nginx.org
U> http://mailman.nginx.org/mailman/listinfo/nginx-ru


--
С уважением

Andrey Repin (hell-for-yahoo@umail.ru) пятница, 14.12.2012, <08:08>
_______________________________________________
nginx-ru mailing list
nginx-ru@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-ru
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: 282
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