By chronodust
Hello I think I’ve run into a bad written configuration files issue, but first of all my configuration:
Current config: Debian nginx php php-fpm APC MariaDB wordpress
Cause of the problem encountered: after installing all the said components, the wordpress site was working well, but the url displayed the IP as the domain name of my site instead of the correct “mydomain.tld” or “www.mydomain.tld”. I managed to solve this putting the following rewrite rule in the main config file of my site in /sites-available
server { server_name _; rewrite ^ $scheme://www.mydomain.tld$request_uri last; }
BUT, having this rule active locks me out of the wordpress administration page (mydomain.tld/wp-admin/) in a way that seems to be that this rule triggers a loop during the authentication process at “mydomain.tld/wp-login.php” page redirecting at the same page (wp-login.php).
I’d say im new in nginx managing and i want to figure out what the #?@! is wrong
thanks for all suggestions
Mars
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Shouldn’t need a rewrite rule. Have you tied something like this: <br> <br>server_name example.org www.example.org; <br>instead of <br>server_name _; ?
Of course, that entry was already there before trying to solve the url-IP/domain issue having the sites-available configuration file as follow: <br> <br>/etc/nginx/sites-available/mydomain.tld <br>-------------------------------------------------------- <br>#server { <br># server_name _; <br># rewrite ^ $scheme://www.mydomain.tld$request_uri last; <br>#} <br> <br>server { <br> #listen 80; ## listen for ipv4; this line is default and implied <br> #listen [::]:80 default_server ipv6only=on; ## listen for ipv6 <br> <br> root /usr/share/nginx/www/mydomain.tld; <br> index index.html index.htm index.php; <br> <br> include global/common.conf; <br> include global/wordpress.conf; <br> <br> server_name mydomain.tld www.mydomain.tld; <br> <br> location /doc/ { <br> alias /usr/share/doc/; <br> autoindex on; <br> allow 127.0.0.1; <br> allow ::1; <br> deny all; <br> } <br>} <br>-------------------------------------------------------- <br>(he rewrite-trick is currently commented) <br> <br> <br>For completeness ill add the included configuration files, may this will help. <br> <br>/etc/nginx/global/wordpress.conf <br>------------------------------------------------ <br>location / { <br> try_files $uri $uri/ /index.php?$args; <br>} <br> <br>location ~* /(?:uploads|files)/..php$ { <br> deny all; <br>} <br> <br>location ~ .php$ { <br> try_files $uri =404; <br> fastcgi_split_path_info ^(.+.php)(/.+)$; <br> fastcgi_pass unix:/var/run/php5-fpm.sock; <br> fastcgi_index index.php; <br> include fastcgi_params; <br>} <br> <br>rewrite /wp-admin$ $scheme://$host$uri/ permanent; <br> <br>location ~ ^.+.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ { <br> access_log off; log_not_found off; expires max; <br>} <br>------------------------------------------------ <br> <br> <br>/etc/nginx/global/common.conf <br>--------------------------------------------- <br>listen 80; <br> <br>location = /favicon.ico { <br> log_not_found off; <br> access_log off; <br>} <br> <br>location = /robots.txt { <br> allow all; <br> log_not_found off; <br> access_log off; <br>} <br> <br>error_page 404 /404.html; <br> <br>error_page 500 502 503 504 /50x.html; <br> location = /50x.html { <br> root /usr/share/nginx/www; <br> } <br> <br>location ~ /. { <br> deny all; <br>} <br> <br>location ~* ^.+.(js|css|swf|xml|txt|ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ { <br> access_log off; log_not_found off; expires 30d; <br>} <br>--------------------------------------------- <br> <br> <br>
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.