1

my conf @/etc/nginx/conf.d/:

server{
    listen 443 ssl http2;
    server_name api.opera.test.com; 
    client_max_body_size 1G;

    ssl on;
    ssl_certificate  /etc/nginx/cert/_.test.com.crt;
    ssl_certificate_key  /etc/nginx/cert/_.test.com.key;
    ssl_session_timeout 5m;

    location / {
        if ($request_method ~* "(GET|POST)") {
          add_header "Access-Control-Allow-Origin"  *;
        }
        if ($request_method = OPTIONS ) {
          add_header "Access-Control-Allow-Origin"  *;
          add_header "Access-Control-Allow-Methods" "GET, POST, OPTIONS, HEAD";
          add_header "Access-Control-Allow-Headers" "Authorization, Origin, X-Requested-With, Content-Type, Accept";
          return 200;
        }
        proxy_pass http://127.0.0.1:6666/;
        proxy_redirect off;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Fowarded-For $proxy_add_x_forwarded_for;
        proxy_cache_valid 200 3d;
        proxy_ssl_server_name on;
        proxy_ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    }

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
      root   /usr/share/nginx/html;
    }  
}

but when i curl the host i proxied, it returned:

[root@develop conf.d]# systemctl restart nginx
[root@develop conf.d]# curl -k http://api.opera.test.com:6666
hello world!
[root@develop conf.d]# curl -k https://api.opera.test.com

<html>
<head><title>404 Not Found</title></head>
<body bgcolor="white">
<center><h1>404 Not Found</h1></center>
<hr><center>nginx/1.14.0</center>
</body>
</html>

and i tried use proxy_pass http://127.0.0.1:6666; instead of proxy_pass http://127.0.0.1:6666/;, unfortunately, doesn't work for me.

3
  • 1
    Point to note - ‘ssl on;’ ssl directive is obsolete and should not be used anymore. See nginx.org/en/docs/http/ngx_http_ssl_module.html#ssl. What do nginx logs show for the 404 error ? Commented Dec 9, 2018 at 10:59
  • @ben5556 thx guy! I found the error in nginx logs: 2018/12/10 20:13:04 [crit] 31321#31321: *1 connect() to 127.0.0.1:6666 failed (13: Permission denied) while connecting to upstream, client: 192.168.19.15, server: api.opera.test.com, request: "GET /favicon.ico HTTP/2.0", upstream: "http://127.0.0.1:6666/favicon.ico", host: "api.opera.test.com", referrer: "https://api.opera.test.com/" . Commented Dec 10, 2018 at 14:23
  • 1
    @ben5556 and this command help me resolved the problem: setsebool -P httpd_can_network_connect 1 thx again! Commented Dec 10, 2018 at 14:24

1 Answer 1

0

this command help me resolved the problem: setsebool -P httpd_can_network_connect 1

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.