1. apache通过.htaccess
以绑定新浪sae应用为例,先将域名绑定至某个服务器,然后在.htaccess中写入以下代码:
1 2 3 |
RewriteEngine On RewriteBase / RewriteRule ^(.*)$ http://mysmf.sinaapp.com/$1 [P] |
2. nginx
仍以绑定新浪sae应用为例,先将域名绑定至某个服务器,再修改Nginx的配置文件,添加如下:
1 2 3 4 5 6 7 8 9 10 11 12 |
server { listen 80; server_name yourdomain.com; location / { proxy_pass http://smf.sinaapp.com/; proxy_redirect off; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } } |
添加好后,先执行:/usr/local/nginx/sbin/nginx -t 检查配置是否正常,如果显示:the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok configuration file /usr/local/nginx/conf/nginx.conf test is successful 则正常,否则按错误提示修改配置。
再执行 kill -HUP cat /usr/local/nginx/logs/nginx.pid
使配置生效,域名解析生效后就可以通过yourdomain.com 访问smf.sinaapp.com了。
发表回复