How to use nginx to forward port 9000 to port 80 locally?
習慣沉默
習慣沉默 2017-05-16 17:26:34
0
2
562

I want to try the third-party login API, but the other party will only redirect to port 80. I want to forward port 9000 to port 80 locally. I wrote it under /etc/ngnix/sites-enabled/ A file and then run
service nginx reload

  1 server {
  2         listen 80;
  3         server_name 127.0.0.1;
  4         location / {
  5                 proxy_pass http://localhost:9000;
  6                 proxy_set_header Host $host;
  7                 proxy_set_header X-Real-IP $remote_addr;
  8                 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  9                 proxy_redirect off;
 10         }
 11 }

I referred to some online resources, but there were no local examples. I tried it myself, but I still couldn't access my 127.0.0.1:9000## from 127.0.0.1 # There is a default file under the configuration file directory. Does it have any impact? Is there anything wrong with the configuration file I wrote?

習慣沉默
習慣沉默

reply all(2)
大家讲道理

will

server_name 127.0.0.1
Change to

server_name localhost

Try it

仅有的幸福

server_name must be configured as a domain name, otherwise nginx itself uses 127.0.0.1. Wouldn’t it be impossible to tell whether you are accessing nginx or the server on port 9000?

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template