Answer the question
In order to leave comments, you need to log in
How to setup nginx reverse proxy for apache?
There is a site to turn on apache. Installed nginx there. centos system. I can't set up nginx as a reverse proxy. error 502 comes out. the site itself at the local address works with a bang (192.168.1.3:8080). at 192.168.1.3:80 the nginx test page comes out.
nginx.conf
user nginx;
worker_processes 10;
error_log /var/log/nginx/error.log debug;
pid /var/run/nginx.pid;
events {
worker_connections 20000;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] $status '
'"$request" $body_bytes_sent "$http_referer" '
'"$http_user_agent" "http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 30;
send_timeout 900;
server_tokens off;
server {
listen 192.168.1.3:80;
server_name mysite.ru www.mysite.ru;
charset UTF-8;
error_page 404 = @fallback;
location / {
proxy_pass http://127.0.0.1:8080;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_buffer_size 8k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 10m;
}
location ~* ^.+\.(bmp|jpg|jpeg|gif|ico|png|css|doc|txt|js|zip|iso|tgz|gz|rar|bz2|7z|xls|exe|pdf|ppt|tar|wav|avi|rtf|mp3|mp4|mov|mpeg|mpg|eot|ttf|woff|woff2)$ {
expires 300d;
root /var/www/html/mysite.ru;
proxy_redirect off;
access_log off;
}
location @fallback {
proxy_pass http://127.0.0.1:8080;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
}
}
}
<VirtualHost *:8080>
ServerName mysite.ru
AddDefaultCharset UTF-8
CustomLog /dev/null combined
DocumentRoot /var/www/html/mysite.ru
ServerAdmin [email protected]
ServerAlias www.mysite.ru
AddType application/x-httpd-php .php .php3 .php4 .php5 .phtml
AddType application/x-httpd-php-source .phps
php_admin_value open_basedir "/var/www/html/mysite.ru:."
php_admin_value sendmail_path "/usr/sbin/sendmail -t -i -f [email protected]"
php_admin_value upload_tmp_dir "/var/www/html/mysite.ru/mod-tmp"
php_admin_value session.save_path "/var/www/html/mysite.ru/mod-tmp"
</VirtualHost>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question