Score:1

Nginx behind Apache

nl flag

I have an apache who is hosting websites one is 000-default.conf for www.domain1.com
another one is domain2.conf for www.domain2.com and has a config like this

<VirtualHost *:80>

    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    ServerName activity.domain2.com
    ProxyPass / http://activity.domain2.com:8000
    ProxyPassReverse / http://activity.domain2.com:8000
</VirtualHost>

domain2 is pointing http://activity.domain2.com:8000 that was served by Nginx

for Nginx the server is configured like this

server {
    listen 8000;
    server_name activity.domain2.com;

    location = /favicon.ico { access_log off; log_not_found off; }
    location /static/ {
        root /root/domain2;
    }

    location / {
        include proxy_params;
        proxy_pass http://unix:/run/gunicorn.sock;
    }

Everything is fine with www.domain1.com
Except, when I load www.domain2.com, only html file is served but static file request is error with code 502 proxy error

How can I fix this?

Update:

I decide to use nginx infront of Apache instead to fix the problem. But still want to know the answer if possible.
in flag
A 5xx error usually has a corresponding entry in the error log with a clear error message. Check your logs.
in flag
Might be a missing slash after the "8000"s
Score:1
us flag
Rob

For starters: it looks like you miss a trailing slash

ProxyPass / http://activity.domain2.com:8000
                                            ^
                           add a "/" here _/

From the manual:

If the first argument ends with a trailing /, the second argument should also end with a trailing /, and vice versa. Otherwise, the resulting requests to the backend may miss some needed slashes and do not deliver the expected results.

Second a proxy error is usually recorded in your (error) logs and like with most errors, the log entry will usually be accompanied by more useful debugging information than what gets returned to a site visitor. First check in the apache logs, but don't forget to also look at the logs for the nginx back-end server.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.