I am trying to configure nginx with wordpress.
the Apache server is running on port 8083.
the wordpress url is https://dhahbya.com
my nginx config file is :
server {
listen *:443 ssl;
server_name www.dhahbya.com dhahbya.com;
ssl_certificate ****************;
ssl_certificate_key **************;
location / {
proxy_pass http://127.0.0.1:8083;
}
}
server {
listen 80;
server_name *.dhahbya.com;
return 301 https://$host$request_uri;
}
the issue is that when I try to navigate in the website it redirects me to 127.0.0.1:8083.
2
Answers
the work around was to remove the apache server and configure nginx to run wordpress.
According to redirect responce you showed in comments (please, use markdown formatting in the future to post such a things):
This redirect is coming from the WordPress core, and the most probable reason is that WordPress can’t detect the original request was made using the HTTPS protocol. Usually such problems are solved using the
X-Forwarded-...
HTTP headers:However for some unknown reasons WordPress didn’t try to detect original request scheme using the non-standard yet widely used
X-Forwarded-Proto
HTTP header, theis_ssl()
WordPress function looks like the following (at the time this being written):The very common solution is to add this functionality to the
wp-config.php
file by yourself:However I didn’t like it since the same can be achieved without making changes to the WordPress files. If your upstream is an apache server using
mod_php
module, you can set thatHTTPS
variable from the apache configuration the following way:And if you serve WordPress by your upstream with another nginx instance via PHP-FPM, you can make that instance setting the
HTTPS
FastCGI variable with thefastcgi_param
directive according to theX-Forwarded-Proto
HTTP header value: