Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
578 views
in Technique[技术] by (71.8m points)

file upload - 502 error when uploading an image - nginx

I have sorted CORS issues in my application and now i still have one issue which is getting 502 error when uploading an image.

My nginx config for backend is

server {

    server_name api.backend;

    location / {
        add_header 'Access-Control-Allow-Origin' '*';
        add_header 'Access-Control-Allow-Headers' 'Origin, X-Requested-With, Content-Type, Accept, X-Access-Token';
        add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT';
        proxy_pass http://localhost:4000;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;

    }

}

And my nginx config for front end is

server {

    server_name www.frontend.com frontend.com;

    root /var/www/html;
    index index.html;

    location / {
        try_files $uri $uri/ /index.html;
     }

}

And this is the network tab of the request which i get 502 error

enter image description here

I tried adding these lines but no luck

proxy_buffer_size 128k;
proxy_buffers 4 256k;
proxy_busy_buffers_size 256k;

What could be the reason for this issue and how can i fix it? Thanks in advance :)

question from:https://stackoverflow.com/questions/66067281/502-error-when-uploading-an-image-nginx

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...