B
B
Bisekenov2018-06-02 14:18:32
Nginx
Bisekenov, 2018-06-02 14:18:32

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

spoiler
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;
}
}
}

in the /etc/httpd/conf.d/mysite.conf folder
spoiler
<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>

where and what am I doing wrong? I use the instructions from the Internet, from habr to different
instructions are different, from different sources. tried everything. everything is exactly the same 502 Bad geteway
error.log:
2018/06/02 15:14:23 [crit] 97716#0: *1 connect() to 192.168.1.3:8080 failed (13: Permission denied) while connecting to upstream , client: 37.151.140.1, server: mysite.ru, request: "GET / HTTP/1.1", upstream: " 192.168.1.3:8080 ", host: "mysite.ru"

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
Fixid, 2018-06-02
@Bisekenov

This is running SELinux.
To disable the ban:
setsebool -P httpd_can_network_connect 1

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question