0
我刚在我的VPS上安装了Nginx作为VestaCP的功能。Nginx的网址掩码到另一个域
我试图做的是对URL屏蔽http://example.com
到http://12345.com
,所以当用户访问http://example.com/path/file.mp4
他们将看到的http://12345.com/path/file.mp4
但是浏览器仍然显示的URL http://example.com/path/file.mp4
内容。
我使用Google搜索并找到了一个主题here。它看起来像我正在寻找的答案。然而,当我将他的代码应用到nginx.conf时,VestaCP显示Error: nginx failed to start with new config
并停止工作。
下面是代码:
server {
listen 80;
server_name sub.example.com;
location/{
proxy_pass https://123.12.12.12;
rewrite ^/$ /path last;
}
}
这是对我来说是正确的解决方案?我对这个完全陌生,所以我不知道我是否做得对。
编辑:我能够使用Apache .htaccess完成工作。我如何将其转换为与Nginx一起使用?
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase/
RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$ [NC]
RewriteRule^http://12345.com%{REQUEST_URI} [L,NE,P]
我想保存配置文件'错误时,这个错误:nginx的启动失败,新config' –
运行'nginx的-t' ,可能还有一些其他配置也正在加载。使用'find/etc/nginx -name'* conf *“'来查看所有配置在那里 –
这就是我运行命令时显示的内容: ' nginx:配置文件/etc/nginx/nginx.conf语法是好的 nginx:配置文件/etc/nginx/nginx.conf测试成功 ' –