能帮助我实现以下目标吗?
我希望http://bla.domain.com指向以下链接。
http://bla.example.com:4321/?nick=Nick.....&&channels=Bulgaria%2CSofia%2Csex%2C30-40&prompt=1&uio=OD1mYWxzZSY5PXRydWUmMTI9dHJ1ZQf0&prompt=1
我已经关注了原始的nginx内容 - > https://www.nginx.com/resources/wiki/start/topics/recipes/qwebirc/
目前index.html没有按照我想要的方式呈现
所以另一个更好的解决方案是当有人打开bla.example.com打开空洞链接(http://bla.example.com:4321/?nick=Nick.....&&channels=Bulgaria%2CSofia%2Csex%2C30-40&prompt=1&uio=OD1mYWxzZSY5PXRydWUmMTI9dHJ1ZQf0&prompt=1),但我不希望提出tho hole链接,因为很难记住。
你可以在下面查看我迄今为止所做的事情。
server { server_name bla.example.com;
location / {
autoindex on;
autoindex_exact_size off;
root /home/user/qwebirc/;
index index.html;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_buffering off;
proxy_pass http://127.0.0.1:4321;
}
#location / {
# autoindex on;
# autoindex_exact_size off;
# root /home/user/qwebirc/;
# index index.html;
# try_files $uri $uri/ @proxy;
#}
#location @proxy {
# proxy_set_header X-Real-IP $remote_addr;
# proxy_set_header Host $host;
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# proxy_buffering off;
# proxy_pass http://127.0.0.1:4321;
#}
location ~* \.php$ {
#include fastcgi.conf # I include this in http context, it's just here to show it's required for fastcgi!
try_files $uri =404; # This is not needed if you have cgi.fix_pathinfo = 0 in php.ini (you should!)
fastcgi_pass 127.0.0.1:9000;
}
### Logs ###
access_log /var/log/nginx/example.com.access.log;
error_log /var/log/nginx/example.com.error.log;
}
请记住,我已尝试使用评论内容而不是现在正在运行它。
下面是位于/ home / user / qwebirc /
中的index.html<html lang="en" class="no-js">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<style>
html body {width: 100%;height: 100%;padding: 0px;margin: 0px;overflow: hidden;font-family: arial;font-size: 10px;color: #6e6e6e;background-color: #000;} #preview-frame {width: 100%;background-color: #fff;}</style>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script>
var calcHeight = function() {
$('#preview-frame').height($(window).height());
}
$(document).ready(function() {
calcHeight();
});
$(window).resize(function() {
calcHeight();
}).load(function() {
calcHeight();
});
</script>
</head>
<body>
<iframe id="preview-frame" src="http://bla.example.com/?nick=Nick.....&&channels=Bulgaria%2CSofia%2Csex%2C30-40&prompt=1&uio=OD1mYWxzZSY5PXRydWUmMTI9dHJ1ZQf0&prompt=1" name="preview-frame" frameborder="0" noresize="noresize">
</iframe>
</body>
</html>
答案 0 :(得分:0)
您将查询字符串附加到根URI并将其传递给代理。将代理分成两个location
blocks可能最容易,一个用于根URI,另一个用于所有其他URI。公共proxy
语句可以移动到外部块中并由两者继承。
server {
server_name bla.example.com;
root /home/kiril/qwebirc;
index index.html;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_buffering off;
location = / {
proxy_pass "http://127.0.0.1:4321/?nick=Nick.....&&channels=Bulgaria%2CSofia%2Csex%2C30-40&prompt=1&uio=OD1mYWxzZSY5PXRydWUmMTI9dHJ1ZQf0&prompt=1";
}
location / {
proxy_pass http://127.0.0.1:4321;
}
location ~* \.php$ {
try_files $uri =404;
fastcgi_pass 127.0.0.1:9000;
}
access_log /var/log/nginx/bla.example.com.access.log;
error_log /var/log/nginx/bla.example.com.error.log;
}
proxy_pass
值包含在引号中,因为它包含嵌入的;
。
答案 1 :(得分:0)
所以当前配置看起来像这样并且不起作用。我无法启动nginx。
server { server_name bla.example.com;
location / {
autoindex on;
autoindex_exact_size off;
root /home/kiril/qwebirc/;
index index.html;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_buffering off;
#proxy_pass http://127.0.0.1:4321;
}
location = / {
proxy_pass "http://127.0.0.1:4321/?nick=Nick.....&&channels=Bulgaria%2CSofia%2Csex%2C30-40&prompt=1&uio=OD1mYWxzZSY5PXRydWUmMTI9dHJ1ZQf0&prompt=1";
}
location / {
proxy_pass http://127.0.0.1:4321;
}
location ~* \.php$ {
#include fastcgi.conf # I include this in http context, it's just here to show it's required for fastcgi!
try_files $uri =404; # This is not needed if you have cgi.fix_pathinfo = 0 in php.ini (you should!)
fastcgi_pass 127.0.0.1:9000;
}
### Logs ###
access_log /var/log/nginx/bla.example.com.access.log;
error_log /var/log/nginx/bla.example.com.error.log;
}
在上述位置取消注释proxy_pass http://127.0.0.1:4321;
并在其下方将其删除,但它的工作方式相同。它仍然无法达到要求。