Answer the question
In order to leave comments, you need to log in
Question about Nginx and Apache config. How to set up subdomains?
Hi all!
The site is powered by Nginx + Apache.
Please advise how to resolve this issue. The task is to get the value of the subdomain (*)
NGINX
server {
listen 80;
server_name *.site.com;
location / {
include /etc/nginx/proxy.conf;
}
#Static files location
location ~*^.+\.(jpg|jpeg|gif|png)$ {
root /home/{ИМЯ ПОДДОМЕНА};
}
}
<VirtualHost *:8080>
ServerName site.com
ServerAlias *.site.com
DocumentRoot /home/{ИМЯ ПОДДОМЕНА}
</VirtualHost>
Answer the question
In order to leave comments, you need to log in
If for all sites 1 config
server {
listen 80 default;
server_name _;
server_name_in_redirect off;
resolver 127.0.0.1;
error_page 404 = @fallback;
#--------------Все 404 отдаем на обработку апача-------------------------------
location @fallback {
proxy_pass http://$host:82;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
}
#--------------Статический контент отдаем на прямую-----------------------------
location ~* ^.+\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js|swf|flv|mp3)$ {
root /var/www/$host/web;
access_log off;
expires 30d;
}
#--------------HTML Вывел отдельно посколку файлы могут быть динамические-------
location ~* ^.+\.(htm|html)$ {
root /var/www/$host/web;
access_log off;
expires 30d;
}
# -------------Основнйо локейшен -----------------------------------------------
location / {
root /var/www/$host/web;
index index.php index.html index.htm;
access_log off;
proxy_pass http://$host:82;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
#-------------- Настройки для phpmyadmin----------------------------------------
location /phpmyadmin {
root /usr/share/;
index index.php index.html index.htm;
location ~ ^/phpmyadmin/(.+\.php)$ {
try_files $uri =404;
root /usr/share/;
proxy_pass http://$host:82;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
root /usr/share/;
}
}
location /phpMyAdmin {
rewrite ^/* /phpmyadmin last;
}
#------------- WEBMAIL----------------------------------------------------------
location /webmail {
root /var/www/apps;
index index.php index.html index.htm;
proxy_pass http://$host:82;
proxy_set_header X-Real-IP $remote_addr;
location ^~ /awstats-icon {
alias /usr/share/awstats/icon/;
access_log off;
}
location ^~ /awstatscss {
alias /usr/share/doc/awstats/examples/css/;
access_log off;
}
location ^~ /awstatsclasses {
alias /usr/share/doc/awstats/examples/classes/;
access_log off;
}
} # Закрывает весь server !!!
server {
#------- Server configuration---------------------------------------------------
listen 80;
server_name infoodessa.com www.infoodessa.com 176.31.8.150;
root /var/www/infoodessa.com/web;
#-------- Error page ----------------------------------------------------------
error_page 404 = @fallback;
location @fallback {
proxy_pass http://infoodessa.com:82;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
}
#-------DEV--------------------------------------------------------------------
error_page 555 = @pass;
location @pass {
auth_basic "Unauthorized";
auth_basic_user_file /var/www/dev_htpasswd;
proxy_pass http://infoodessa.com:82;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
}
# ------ Log configuration ----------------------------------------------------
access_log off;
#error_log /var/log/ispconfig/httpd/infoodessa.com/nginx_error.log error;
#access_log /var/log/ispconfig/httpd/infoodessa.com/nginx_access.log combined;
#------ static content --------------------------------------------------------
location ~* ^.+\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js|swf|flv|mp3)$ {
root /var/www/infoodessa.com/web;
access_log off;
expires 30d;
}
#------ Locations configuration -----------------------------------------------
# global locations
# alias to local error docsinfoodessa.com www.infoodessa.com
location ^~ /error { root /var/www; }
# default location
location / {
index index.php index.html index.htm;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://infoodessa.com:82;
proxy_set_header Host $host;
if ($http_host ~* "^(dev|old|www.dev)\..*\..{2,8}$"){
return 555;
}
if ($http_host ~* "^.*\.ks03\.ru$"){
return 555;
}
}
#------- Directives configuration ---------------------------------------------
# для битрикс монитора
add_header X-Content-Type-Options nosniff;
add_header X-Frame-Options SAMEORIGIN;
include /etc/nginx/locations.d/*.conf;
<Directory /var/www/infoodessa.com>
AllowOverride None
Order Deny,Allow
Deny from all
</Directory>
<VirtualHost *:82>
DocumentRoot /var/www/infoodessa.com/web
ServerName infoodessa.com
ServerAlias www.infoodessa.com
ServerAlias www.109.74.130.76 109.74.130.76
ServerAlias www.176.31.8.150 176.31.8.150
ServerAdmin [email protected]
ErrorLog /var/log/ispconfig/httpd/infoodessa.com/error.log
Alias /error/ /var/www/error/
<Directory /var/www/error/>
Options +FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
ErrorDocument 400 /error/400.html
ErrorDocument 401 /error/401.html
ErrorDocument 403 /error/403.html
ErrorDocument 404 /error/404.html
ErrorDocument 405 /error/405.html
ErrorDocument 500 /error/500.html
ErrorDocument 502 /error/502.html
ErrorDocument 503 /error/503.html
<Directory /var/www/infoodessa.com/web>
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
<Directory /var/www/clients/client2/web3/web>
Options +FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
<IfModule mod_suexec.c>
SuexecUserGroup web3 client2
</IfModule>
# Clear PHP settings of this website
<FilesMatch ".+\.ph(p[345]?|t|tml)$">
SetHandler None
</FilesMatch>
# php as fast-cgi enabled
# For config options see: http://httpd.apache.org/mod_fcgid/mod/mod_fcgid.html
<IfModule mod_fcgid.c>
FcgidIdleTimeout 300
FcgidProcessLifeTime 3600
# FcgidMaxProcesses 1000
FcgidMinProcessesPerClass 0
FcgidMaxProcessesPerClass 10
FcgidConnectTimeout 3
FcgidIOTimeout 1600
FcgidBusyTimeout 3600
FcgidMaxRequestLen 1073741824
</IfModule>
<Directory /var/www/infoodessa.com/web>
<FilesMatch "\.php[345]?$">
SetHandler fcgid-script
</FilesMatch>
FCGIWrapper /var/www/php-fcgi-scripts/web3/.php-fcgi-starter .php
FCGIWrapper /var/www/php-fcgi-scripts/web3/.php-fcgi-starter .php3
FCGIWrapper /var/www/php-fcgi-scripts/web3/.php-fcgi-starter .php4
FCGIWrapper /var/www/php-fcgi-scripts/web3/.php-fcgi-starter .php5
Options +ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
<Directory /var/www/clients/client2/web3/web>
<FilesMatch "\.php[345]?$">
SetHandler fcgid-script
</FilesMatch>
FCGIWrapper /var/www/php-fcgi-scripts/web3/.php-fcgi-starter .php
FCGIWrapper /var/www/php-fcgi-scripts/web3/.php-fcgi-starter .php3
FCGIWrapper /var/www/php-fcgi-scripts/web3/.php-fcgi-starter .php4
FCGIWrapper /var/www/php-fcgi-scripts/web3/.php-fcgi-starter .php5
Options +ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
# add support for apache mpm_itk
<IfModule mpm_itk_module>
AssignUserId web3 client2
</IfModule>
</VirtualHost>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question