Getting Nginx to point to a specific index.html page outside of /var/www/

可紊 提交于 2020-01-03 05:37:19

问题


I'm trying to get nginx to point to my index.html page along with imgs, CSS, JS, etc. that lies in a GoPATH, which is outside of /var/www/. My overall objective is to allow my website to run on port 80 and not 8080. Is it possible to do this? Below is what I currently have in the nginx.conf.

user www-data;

    http {
            include /etc/nginx/proxy.conf;
            index   index.html
    }

                  server { # simple reverse-proxy
            listen       80;
            server_name  dtrinh.com www.dtrinh.com;
            access_log   logs/dtrinh.access.log  main;

            # serve static files
            # serve static files
            location /  {
              root    /go/src/ps/views/default/index.html;
              expires 30d;

            # pass requests for dynamic content to rails/turbogears/zope, et al
            location / {
              proxy_pass      http://127.0.0.1:8080;
            }

        }

回答1:


location / {
    root /go/src/ps/views/default;
    error_page 404 = @backend;
    expires 30d;
}

location @backend {
    proxy_pass http://127.0.0.1:8080;
}

Reference:

  • http://nginx.org/r/root
  • http://nginx.org/r/error_page
  • http://nginx.org/r/location


来源:https://stackoverflow.com/questions/25842091/getting-nginx-to-point-to-a-specific-index-html-page-outside-of-var-www

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!