Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I get 503 error with Images and CSS files #1296

Closed
wp-coin opened this issue Jun 1, 2024 · 6 comments
Closed

I get 503 error with Images and CSS files #1296

wp-coin opened this issue Jun 1, 2024 · 6 comments

Comments

@wp-coin
Copy link

wp-coin commented Jun 1, 2024

are my settings wrong? what is causing my sample php app to block images and linked files?

[app config]

curl -X PUT --data-binary '{
  "listeners": {
      "127.0.0.1:8080": {
          "pass": "applications/php"
      }
  },
  "applications": {
      "php": {
          "type": "php",
          "root": "var/www/mywebsite.org"
      }
  }
  }' --unix-socket /path/to/control.unit.sock http://localhost/config/

Screenshot 2024-05-31 200513

default.conf

upstream my_upstream {
server  127.0.0.1:8080;
}

server {
    listen 80;
    listen [::]:80;
    server_name www.mysite.org;
    root        /var/www/wordpress/;

    # Redirect HTTP to HTTPS
    return 301 https://$host$request_uri;
}


server {

    listen 443 ssl;
    listen [::]:443 ssl;
    http2 on;
    server_name mysite.org www.mysite.org;

  include h5bp/tls/ssl_engine.conf;
  include h5bp/tls/certificate_files.conf;
  include h5bp/tls/policy_balanced.conf;

  # Path for static files
  root /var/www/wordpress/;
	index index.html index.php;


# Proxy configuration
    location / {
        proxy_pass http://my_upstream;
        proxy_socket_keepalive on;
        proxy_http_version 1.1;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Connection "";
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-Proto $scheme;

    }




}


@lcrilly
Copy link
Contributor

lcrilly commented Jun 3, 2024

Check the nginx and Unit logs to see where that 503 is coming from.

Your nginx configuration is confusing and ambiguous, with root and location / in the server{} block. How does nginx know which URIs to serve locally, and which ones to proxy to Unit?

I'd recommend to keep nginx as the HTTP/2 front-end and have Unit take care of all the Wordpress parts. Remove the root directive and follow https://unit.nginx.org/howto/wordpress/

@wp-coin
Copy link
Author

wp-coin commented Jun 3, 2024

thanks for the info, Unit docs doesn't say much about nginx configuration settings and I don't know much about configuring that.

@lcrilly
Copy link
Contributor

lcrilly commented Jun 3, 2024

Then get it working with Unit and then add NGINX in front for the jobs you need it to do. Unit has no dependency on NGINX and other reverse proxies are available :)

@wp-coin
Copy link
Author

wp-coin commented Jun 3, 2024

ok, are the settings on this script wrong? https://gist.github.com/nginx-gists/bdc7da70b124c4f3e472970c7826cccc

the current configs does not seem to be working

@wp-coin
Copy link
Author

wp-coin commented Jun 3, 2024

sorry for the bother, I got half of it working, how do I get my unit php server listening on 127.0.0.1:8080 to stream content to nginx via reverse proxy?

currently, nginx is showing the www/html/default.html page

my root is: "root": "var/www/mywebsite.org"

/conf.d/default.conf

server {
    listen 80;
    server_name example.com;

    location / {
        return 301 https://$host$request_uri;
    }
}

server {
    listen 443 ssl;
    server_name example.com;

    # SSL configuration
    ssl_certificate /path/to/certificate.crt;
    ssl_certificate_key /path/to/certificate.key;

    location / {
        proxy_pass http://127.0.0.1:8080;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}

@lcrilly
Copy link
Contributor

lcrilly commented Jun 3, 2024

I already linked to the official Unit documentation for Wordpress. As you have already engaged 3 different members of the Unit team here and in the Gist comments, I will convert this issue to a discussion and encourage you to use that as the preferred channel for assistance.

@nginx nginx locked and limited conversation to collaborators Jun 3, 2024
@lcrilly lcrilly converted this issue into discussion #1300 Jun 3, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants