By kazbanoleg
hello i have finished settupng my droplet with this article: https://digitalocean.com/community/articles/how-to-configure-nginx-as-a-front-end-proxy-for-apache, but after restarting their services i got 502 error - Bad Gateway.
netstat output: Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN 27867/mysqld tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 5846/nginx tcp 0 0 127.0.0.1:82 0.0.0.0:* LISTEN 5824/apache2 tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 793/sshd tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 13573/php-fpm.conf) tcp6 0 0 :::4949 :::* LISTEN 24573/munin-node tcp6 0 0 :::22 :::* LISTEN 793/sshd
/etc/nginx/sites-enabled/myexamplesite config: server { listen 80;
root /var/www/;
index index.php index.html index.htm;
server_name myexamplesite.com;
location / {
try_files $uri $uri/ /index.php;
}
location ~ \.php$ {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
proxy_pass http://127.0.0.1:8080;
}
location ~ /\.ht {
deny all;
}
}
/etc/apache2/sites-enabled/myexamplesite config: <VirtualHost 127.0.0.1:82> ServerAdmin webmaster@localhost
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
what is wrong here? it seems that request passes nginx to apache but than something goes wrong
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!
try to restar php service
<br>alternatively (is that a word?) try changin
<br>try_files $uri $uri/ /index.php;
<br>to try_files $uri /index.php?$args;
<br>
<pre>proxy_pass http://127.0.0.1:8080;</pre> You are trying to reverse proxy requests to 127.0.0.1:8080 but I don’t see anything listening on that port.
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.