我想更改nginx开始页面(路径)

时间:2017-10-06 01:03:23

标签: nginx

我的服务器使用meteor,ssl,nginx

调用此url => https://example.com

我想自动更改此网址=> https://example.com/main< - / main是起始页

如何更改?

不要搜索它...

这是我的配置

upstream backend {
  ip_hash;
  least_conn ;
  server localhost:9000;
  server localhost:9002;
}

server {
  listen 443;
  server_name example.com;

  access_log  /var/log/nginx/log  main;


  ssl on;
  ssl_certificate     /etc/letsencrypt/live/example.com/fullchain.pem;
  ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;

  ssl_session_timeout 5m;

  ssl_protocols SSLv3 TLSv1;
  ssl_ciphers 
  ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv3:+EXP;
  ssl_prefer_server_ciphers on;

  location / {
       proxy_pass http://backend;
       proxy_http_version 1.1;
       proxy_set_header Upgrade $http_upgrade;
       proxy_set_header Connection "upgrade";
       proxy_set_header Host $host;
  }
}


server {
   server_name example.com;
   return 301 https://$host$request_uri;
}

谢谢

1 个答案:

答案 0 :(得分:0)

您只需要在location /

中添加简单的重写规则
 location / {
       rewrite ^/$ /main redirect;
       proxy_pass http://backend;
       proxy_http_version 1.1;
       proxy_set_header Upgrade $http_upgrade;
       proxy_set_header Connection "upgrade";
       proxy_set_header Host $host;
  }