golang - Use Nginx reverse proxy to deploy websites written in Go.
習慣沉默
習慣沉默 2017-05-16 17:27:54
0
2
769

This is the path of my go language project (MVC): /home/demo/goproj/src/Test. It listens to port 8080. How to write the Nginx configuration file? ? I've configured it several times but it's still wrong. " location /{} " or write like this " location /Test {}"

習慣沉默
習慣沉默

reply all(2)
伊谢尔伦

Simple version:

location / {
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  proxy_set_header Host $http_host;
  proxy_redirect off;
  proxy_pass http://localhost:8080;
}

Generally static files are provided by nginx, so they can be written like this

root /home/demo/goproj/src/Test/public;
try_files $uri/index.html $uri.html $uri @goapp;

location @goapp {
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  proxy_set_header Host $http_host;
  proxy_redirect off;
  proxy_pass http://localhost:8080;
}
大家讲道理
server {
    listen 80;
    server_name 123.com;

    location / {
    proxy_pass    http://127.0.0.1:8080;
    proxy_redirect default;
        }
}

If there is a level 2 directory then

        location /test {
        proxy_pass    http://127.0.0.1:8080;
        proxy_redirect default;
        }
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!