1
momou 2012-03-20 14:09:50 +08:00
502 Bad Gateway
nginx/0.7.61 |
2
paloalto OP |
3
momou 2012-03-20 14:26:45 +08:00
自检没有报错?
|
4
paloalto OP @momou 刚才代码里没有}闭合,但是加上}闭合之后,还是不行
[root@vps www]# /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 依然跳转到探针页面。 贴出我的nginx.conf文件: user www www; worker_processes 1; error_log /home/logs/nginx_error.log crit; pid /usr/local/nginx/logs/nginx.pid; #Specifies the value for maximum file descriptors that can be opened by this process. worker_rlimit_nofile 51200; events { use epoll; worker_connections 51200; } http { include mime.types; default_type application/octet-stream; #charse gb2312; server_names_hash_bucket_size 128; client_header_buffer_size 32k; large_client_header_buffers 4 32k; client_max_body_size 8m; sendfile on; tcp_nopush on; keepalive_timeout 60; tcp_nodelay on; fastcgi_connect_timeout 300; fastcgi_send_timeout 300; fastcgi_read_timeout 300; fastcgi_buffer_size 64k; fastcgi_buffers 4 64k; fastcgi_busy_buffers_size 128k; fastcgi_temp_file_write_size 128k; gzip on; gzip_min_length 1k; gzip_buffers 4 16k; gzip_http_version 1.0; gzip_comp_level 2; gzip_types text/plain application/x-javascript text/css application/xml; gzip_vary on; #limit_zone crawler $binary_remote_addr 10m; server { listen 80; server_name bod.fm; index index.html index.htm index.php; root /home/www; #limit_conn crawler 20; #location /status { #stub_status on; #access_log off; #} location ~ .*\.(php|php5)?$ { fastcgi_pass unix:/tmp/php-cgi.sock; #fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fcgi.conf; } location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ { expires 30d; } location ~ .*\.(js|css)?$ { expires 12h; } log_format access '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" $http_x_forwarded_for'; access_log /home/logs/access.log access; } server { listen 80; server_name jiyin.it; location / { proxy_pass http://geekiwi.appspot.com/; proxy_redirect off; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } } server { listen 80; server_name yagbodu.com; location / { proxy_pass http://erwenit.appspot.com/; proxy_redirect off; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } } } |
5
lowstz 2012-03-20 14:49:54 +08:00
server {
listen 81; server_name jiyin.it; location / { proxy_redirect off; proxy_pass http://geekiwi.appspot.com; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } } } |
7
lowstz 2012-03-20 14:53:56 +08:00
不是,我只是测试,80也可以
自己vps上测试了可以 |
9
lemonda 2012-03-20 14:59:01 +08:00
本地测试,jiyin.it指向127.0.0.1,反代成功:
vps上jiyin.it应指向vps的IP 只是在http {} 两括号之间加上了: http://gist.github.com/2132139.js |
10
paloalto OP @lowstz 我改动了一下conf文件,然后新加上了你的。结果访问jiyin.it变成一个nginx的欢迎页面了。。。悲催。。。
——————————nginx.conf文件:—————————— user www www; worker_processes 2; error_log /home/logs/nginx_error.log crit; pid /usr/local/nginx/logs/nginx.pid; #Specifies the value for maximum file descriptors that can be opened by this process. worker_rlimit_nofile 51200; events { use epoll; worker_connections 51200; } http { include mime.types; default_type application/octet-stream; #log_format main '$remote_addr - $remote_user [$time_local] "$request" ' # '$status $body_bytes_sent "$http_referer" ' # '"$http_user_agent" "$http_x_forwarded_for"'; #access_log logs/access.log main; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; #gzip on; server { listen 80; server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location / { root html; index index.html index.htm; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # #location ~ \.php$ { # root html; # fastcgi_pass 127.0.0.1:9000; # fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; # include fastcgi_params; #} # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #} } server { listen 81; server_name jiyin.it; location / { proxy_redirect off; proxy_pass http://geekiwi.appspot.com; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } } } |
11
aggron 2012-03-20 15:00:00 +08:00
现在变成 Welcome to nginx!了
|
12
paloalto OP |
13
lowstz 2012-03-20 15:03:08 +08:00
|
14
aggron 2012-03-20 15:05:13 +08:00
server {
listen 80; server_name jiyin.it; location / { proxy_redirect off; proxy_pass http://geekiwi.appspot.com; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } } 这样就OK了, 如果listen 81就得用 http://jiyin.it:81/ 来访问了 |
15
lemonda 2012-03-20 15:06:27 +08:00
@paloalto nginx.conf里就是gist的代码那样了,我是本地测试才把127.0.0.1 jiyin.it写到hosts里的,你把jiyin.it指向199.15.116.122已经可以了。
|
16
ccdjh 2012-03-20 15:11:28 +08:00
server {
listen 80; server_name www.jiyin.it; access_log /var/log/nginx/localhost.access.log; location / { proxy_pass http://ghs.google.com; proxy_set_header Host $host; proxy_redirect off; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarder-For $proxy_add_x_forwarded_for; # root /var/www/nginx-default; # index index.html index.htm; } } |
17
paloalto OP 把listen 81改成了listen 80后还是欢迎页面,会不会是nginx.conf里第一个server对第二个server有干扰?
重新帖一遍现在的nginx.conf的内容: ——————————nginx.conf文件:—————————— user www www; worker_processes 2; error_log /home/logs/nginx_error.log crit; pid /usr/local/nginx/logs/nginx.pid; #Specifies the value for maximum file descriptors that can be opened by this process. worker_rlimit_nofile 51200; events { use epoll; worker_connections 51200; } http { include mime.types; default_type application/octet-stream; #log_format main '$remote_addr - $remote_user [$time_local] "$request" ' # '$status $body_bytes_sent "$http_referer" ' # '"$http_user_agent" "$http_x_forwarded_for"'; #access_log logs/access.log main; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; #gzip on; server { listen 80; server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location / { root html; index index.html index.htm; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # #location ~ \.php$ { # root html; # fastcgi_pass 127.0.0.1:9000; # fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; # include fastcgi_params; #} # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #} } server { listen 80; server_name jiyin.it; location / { proxy_redirect off; proxy_pass http://geekiwi.appspot.com; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } } } |
18
aggron 2012-03-20 15:18:52 +08:00
现在OK的,CTRL+F5看看?
|
20
paloalto OP @ccdjh 新加的access_log是干嘛的?
[emerg]: open() "/var/log/nginx/localhost.access.log" failed (2: No such file or directory) |
22
aggron 2012-03-20 15:22:57 +08:00
是的,能直接访问
CTRL+F5, 或者清空你本地的DNS缓存看看 |
23
paloalto OP |
24
aggron 2012-03-20 15:36:06 +08:00
提交表单后的跳转貌似有点问题:
点“说出来”后,chrome左下角显示”正在向geekiwi.appspot.com提交数据“,然后chrome地址栏就变成了geekiwi.appspot.com,于是显示被墙。再进入jiyin.it可以看到刚发布的内容 |
25
guoquan 2012-03-20 15:44:30 +08:00
^_^ 要不要上个LUManager试试呀 http://www.v2ex.com/t/29571
|
27
guoquan 2012-03-20 16:37:05 +08:00
@paloalto LUManager在vps管理上很全面,web服务器就是apache+nginx+tengine,1.1.9免费版就已经很强悍了,设置个反向代理什么的不在话下。
最近开始走商业化的2.0.x版更加面面俱到,都可以拿出来直接做idc了,个人使用更加游刃有余,欢迎了解哦。 |
28
liuhang0077 2012-03-20 17:06:10 +08:00
不用那么多吧~~~
server { listen 80; server_name www.aaa.com; location / { proxy_pass http://www.bbbb.com/; proxy_redirect off; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } } |
29
CoX 2012-03-20 17:42:11 +08:00
访问了一下,可以正常访问啊
|
30
blacktulip 2012-03-20 17:44:39 +08:00
@guoquan 麻烦您不要在技术讨论帖里面发这种广告了,好好的讨论串里面突然给你插一个这样的帖子
|