Nginx端口可用于所有URL

时间:2016-11-17 18:02:29

标签: nginx

我正在使用#include <opencv2/core/core.hpp> #include <opencv2/highgui/highgui.hpp> #include <opencv2/imgproc/imgproc.hpp> #include <opencv2/features2d/features2d.hpp> #include <opencv2/objdetect/objdetect.hpp> #include <iostream> #include <stdio.h> using namespace std; using namespace cv; char key; int main() { cvNamedWindow("Camera_Output", 1); //Create window CvCapture* capture = cvCaptureFromCAM(CV_CAP_ANY); //Capture using any camera connected to your system while(1){ //Create infinte loop for live streaming IplImage* frame = cvQueryFrame(capture); //Create image frames from capture cvShowImage("Camera_Output", frame); //Show image frames on created window key = cvWaitKey(10); //Capture Keyboard stroke if (char(key) == 27){ break; //If you hit ESC key loop will break. } } key = cvWaitKey(10); cvReleaseCapture(&capture); //Release capture. cvDestroyWindow("Camera_Output"); //Destroy Window return 0; } Docker,这是我的Nginx文件:

default.conf

如此快速的解释:

  • defaut主机服务我的html文件夹,没问题。
  • 网址server{ listen 80 default_server; server_name localhost; location / { root /usr/share/nginx/html; } } server{ listen 80; server_name blog.domain.com; location / { proxy_pass http://MY-IP:8080; } } 提供在端口8080上运行的blog.domain.com应用程序,没问题。

我有另一个应用程序在端口8081(phpMyAdmin)上运行,我的问题是,如果我尝试Wordpresshttp://MY-IP:8081它没关系,我可以访问PhpMyAdmin ...为什么?< / p>

我不希望此端口8081可用于我服务器上的所有网址。

1 个答案:

答案 0 :(得分:0)

PHPMyAdmin仅适用于proxy_pass指令。你可以否认整个地球的位置。我猜Nginx不是侦听端口8080以及80的服务器,而是其他东西正在侦听8080,你希望Nginx代理到该服务器。在这种情况下,这将起作用。这是最小配置:

# first server block    
server {
    listen 80;
    server_name domain.com;
        location / {
        root /usr/share/nginx/html;                
                    }
        ## set phpmyadmin to a different path
        location /phpmyadmin {
        proxy_pass         http://127.0.0.1:8081/phpmyadmin;
        #allow 1.1.1.1;
        # deny all;
                            }
        } # end server
# second server block       
server {
    listen 80;
    server_name blog.domain.com;
        location / {
        proxy_set_header   X-Real-IP $remote_addr;
        proxy_set_header   Host      $http_host;
        proxy_pass         http://i.p.v.4:8080;
                    }
        } # end server