小编ant*_*ant的帖子

如何在JavaScript中进行css3转换后获取元素的位置?

我在stackoverflow上看到了这两种不同的形式,但解决方案对我不起作用.

基本上,我有一个项目,我将翻译.当我执行obj.style.left或obj.offsetLeft时,在元素被翻译之后,我得到0.无论如何,我可以在用css3翻译后得到元素的坐标/位置吗?

我不能使用jQuery(因为我不能也因为我想了解解决方案,而不仅仅是使用库而不了解下面发生的事情)

有任何想法吗?

非常感谢!

javascript css3

21
推荐指数
2
解决办法
2万
查看次数

如何配置expressjs来处理http和https?

我已经搜索了stackoverflow和快速谷歌组,但我仍然很短.

从我收集的内容来看,我可以做以下两件事之一:

1)创建http服务器和https服务器的实例,并将两者设置为侦听两个不同的端口.在路由中,将http请求重定向到https端口.

//app
var app = express.createServer();
var app_secure = express.createServer({key: key, cert: cert});

app.listen(8080);
app_secure.listen(8443);

//routes
app.get("unsecure/path", function(req, res) {
  ...
}

app.get("secure/path", function(req, res) {
  res.redirect("https://domain" + req.path);
}

app_secure.get("secure/path", function(req, res) {
  res.send("secure page");
}
Run Code Online (Sandbox Code Playgroud)

2)做什么TJ Hollowaychuk说:https://gist.github.com/1051583

var http = require("http");
var https = require("https");
var app = express.createServer({key: key, cert: cert});

http.createServer(app.handle.bind(app)).listen(8080);
https.createServer(app.handle.bind(app)).listen(8443);
Run Code Online (Sandbox Code Playgroud)

当我做1时,通常没有问题.然而,管理两台服务器感觉很笨,我觉得应该有更好的方法.

当我做2时,我明白了:

(节点SSL)错误:1408A0C1:SSL例程:SSL3_GET_CLIENT_HELLO:无共享密码

当然,我可以默认选项1,但我真的,我真的想知道为什么我在做选项2时得到"没有共享密码错误".选项2将是我的首选路由.

node.js express

6
推荐指数
2
解决办法
4677
查看次数

Node.js - HTTP通过Squid代理授权问题

我正在尝试使用http.get发出一个简单的请求.但我需要通过Squid代理提出这个请求.这是我的代码:

var http = require('http');
var username = 'username';
var password = 'password';
var host = "proxy_host";
var auth = 'Basic ' + new Buffer(username + ':' + password).toString('base64');

var options = {
  host: host,
  port: 3128,
  path: "http://www.google.com",
  authorization: auth,
  headers: {
    Host: 'www.google.com'
  }
};

var req = http.request(options, function(res) {
  console.log('STATUS: ' + res.statusCode);
  console.log('HEADERS: ' + JSON.stringify(res.headers));
});

req.end();
Run Code Online (Sandbox Code Playgroud)

根据设置代理的操作团队,我的用户名和密码是正确的.问题是我不断获得407 - 授权所需的状态.

我提出请求的方式有问题吗?或者是否需要配置Squid代理?

提前致谢.

squid node.js

4
推荐指数
1
解决办法
3473
查看次数

Nginx - 在离开安全页面时将HTTPS重定向回HTTP

我在Node.js应用程序前面有Nginx.我已将其设置为如果网址中包含/ account,则会重定向到HTTPS.我的问题是 - 如何设置它,以便如果用户离开/帐户URL(单击链接转到主页),它将被发送回HTTP?

这是我的ngnix.conf:

worker_processes  1;

error_log  logs/error.log;

pid        logs/nginx.pid;

events {
    worker_connections  128;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    sendfile        on;

    server_tokens off;

    #keepalive_timeout  0;
    keepalive_timeout  65;
    tcp_nodelay        on;
    proxy_buffer_size   128k;
    proxy_buffers   4 256k;
    proxy_busy_buffers_size   256k;

    gzip  on;

    server {
        listen       80;
        server_name  localhost;

        location / {
            proxy_set_header x-path $uri;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header Host $http_host;
            proxy_set_header X-NginX-Proxy true;
            proxy_pass http://127.0.0.1:3000;
            proxy_redirect off;
        }

        location /account {
          rewrite ^(.*) https://$host$1 permanent; #redirect to https …
Run Code Online (Sandbox Code Playgroud)

nginx node.js express

2
推荐指数
1
解决办法
2360
查看次数

标签 统计

node.js ×3

express ×2

css3 ×1

javascript ×1

nginx ×1

squid ×1