please explicitly possible. have set domain on home server running nginx on ubuntu 15, , have dns pointed it. can use domain access site , if append /subdirectory it, able launch pages inside subdirectories. trying subdomains go directly correct root. ie: mysite.com = /index.htm, subdomain.mysite.com = ./subdirectory files located. have tried every suggestion including popular , criticized, , either error restarting nginx or "server not found" error. i´ve tried setting cname aliases dns server, , doesn´t work either.
the working config file below:
## server { server_name "~^(?<sub>.+)\.domain\.tld$"; index index.php index.html index.htm; root //media/user/ednet/$sub; ssl_certificate removed security ssl_certificate_key removed securityy ssl_protocols tlsv1 tlsv1.1 tlsv1.2; ssl_ciphers high:!anull:!md5; listen 80 default_server; listen [::]:80 default_server; # ssl configuration # listen 443 ssl default_server; listen [::]:443 ssl default_server; # root //media/user/ednet; # add index.php list if using php index index.php index.html index.htm; #=========================locations============================= location / { # first attempt serve request file, # directory, fall displaying 404. try_files $uri $uri/ =404; } error_page 404 /404.html; error_page 500 502 503 504 /50x.html; location = /50x.html { # root /usr/share/nginx/html; } #============================================================php========================================================= location ~ \.php$ { try_files $uri =404; # fastcgi_split_path_info ^(.+\.php) (/.+)$; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; fastcgi_param script_filename $document_root$fastcgi_script_name; include fastcgi_params; } }
==================== i´ve tried proxies, redirects, , else can think of--including reading instructions in nginx manual , wiki. thanks
a quick "server not found" browser suggests dns not set up. subdomains need resolve server's public ip address using either:
- specific cname record pointing main domain specific record
- pointing server's ip address wild (catch-all) record
- pointing server's ip address
changes dns can take many hours propagate.
an error restarting nginx
suggests syntax error in configuration file.
your configuration file contains no obvious syntax errors, there few strange elements:
root
directive appears twiceindex
directive appears twiceroot
directive has 2 leading//
1 do
you have ipv4 , ipv6 configured fine if have ipv6 connection.
you have server marked default_server
means used if server_name
regex not match. therefore, if present server subdomain returns files root, implies regex failed match server
block used default. in case, check regex.
in summary, first priority fix dns. nothing work unless subdomains resolve ip address of server.
Comments
Post a Comment