The original post: /r/nginx by /u/mark1210a on 2024-06-28 20:50:00.
Hey All -
Has anyone been able to get NGINX to forward to an internal IP for Wordpress successfully?
With the NGINX configuration below, Wordpress loads - but the images are missing and the admin page is not accessible. Using the 10.0.0.107 address locally, everything works fine with Wordpress. The real domain has been replaced with domain.com in the file below.
Thanks for any input.
Here’s my config in NGINX:
server {
if ($host =
www.domain.com
) {
return 301 https://$host$request_uri;
}
listen 80;
server_name
www.domain.com
;
return 301 https://www.domain.com$request_uri;
}
server {
server_name
domain.com
;
return 301 https://www.domain.com$request_uri;
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/domain.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/domain.com/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
listen 443;
index index.php index.html index.htm;
server_name
www.domain.com
;
client_max_body_size 500M;
location / {
try_files $uri $uri/ /index.php?$args;
proxy_pass
http://10.0.0.107/wordpress/
;
proxy_read_timeout 90;
proxy_redirect
http://10.0.0.107/
https://www.domain.com/
;
}
location = /favicon.ico {
log_not_found off;
access_log off;
}
location ~* \wordpress\wp-content.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
ssl_certificate /etc/letsencrypt/live/domain.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/domain.com/privkey.pem; # managed by Certbot
ssl_session_cache builtin:1000 shared:SSL:10m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4;
ssl_prefer_server_ciphers on;
access_log /var/log/nginx/domain.access.log;
}
server {
if ($host = domain.com) {
return 301 https://$host$request_uri;
}
listen 80;
server_name
domain.com
;
return 404; # managed by Certbot
}