PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0
Showing posts with label webserver. Show all posts
Showing posts with label webserver. Show all posts

Monday, November 14, 2022

[FIXED] How to not get blacklisted, trash/spam moved for sending emails?

 November 14, 2022     apache, linux, mailing, spam, webserver     No comments   

Issue

How to find my limitations and methods to not get blacklisted, trash/spam moved for sending emails?

I have growing number of like 10000 e-mail adressess and e-mails that I have to send on daily basis regarding:

  • user registration
  • reminders
  • confirmations
  • news

I want to send mailing to my community but am afraid of beeing blacklisted. It happend few times when years back then was sending mailings from virtual server.

Now I own my dedicated server and want come back to sending lare ammount of e-mails (all sort of reasons listed above).


Solution

  • Make sure your mailing list is opt-in or provide an easy way for your community members to opt-out.
  • Provide the opt-in/out link directly in every email message.
  • Make it highly visible!
  • Send only to your community members.
  • Don't annoy them everyday with meaningless crap.
  • Even being careful and providing opt-in/out for your members you can't force them to use it.
  • Realize that email clients make it easier to just flag it as spam.


Answered By - Dave Rager
Answer Checked By - David Goodson (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Sunday, November 13, 2022

[FIXED] Why I see another web site at my https addres?

 November 13, 2022     https, iis, plesk, webserver     No comments   

Issue

Can anybody explain why I see another web site at my http secure address. I don't have a certificate. I can manage files from folder httpsdocs but cannot access them from web. Also httpsdocs is empty. https://innovacube.com/

And base of my problem is Google indexes my https domain but I cannot denny Google Bot.


Solution

You're sharing IP addresses with another site - you'll see that both www.innovacube.com and www.cokyader.com resolve to 92.199.202.62. HTTP/1.1 allows this because you also send a host header

GET / HTTP/1.1
Host: www.innovacube.com

so the web server knows which site to serve for a given connection.

It isn't, however, possible to do this for HTTPS. The problem is that the certificate negotiation happens before the server gets to HTTP so you can't switch depending on the site that the browser really means. Therefore you can only host one HTTPS site per IP and this IP is hosting cokyader.com. (There are proposed extensions to help fix this but I've never seen any progress on this.)

If you want your own separate HTTPS site then your host will have to allocate you your own separate IP address.



Answered By - Rup
Answer Checked By - Cary Denson (PHPFixing Admin)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

[FIXED] How to install Apache on plesk17 in server windows

 November 13, 2022     .htaccess, apache, iis, plesk, webserver     No comments   

Issue

I have Windows server and install plesk17 on that. I have custom CMS and that used .httpaccess .

But my web server is iis and not to run .httpaccess; I can't change server to Linux...

Is Apache Installed On plesk17 Windows?

My main problem is just not running the following code:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /cms/index.php?/$1 [L]�

I would appreciate it if I guide you so that I can solve my problem


Solution

I can help with converting your .htaccess file to a URLRewrite rule. Please note that URL Rewrite is not part of default IIS install and must be downloaded. Available here: https://www.iis.net/downloads/microsoft/url-rewrite

Next the commands to create your URL Rewrite rule for Default Website is as follows:


Add-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST/Default Web Site'  -filter "system.webServer/rewrite/rules" -name "." -value @{name='ConvertedRule';stopProcessing='True'}
Set-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST/Default Web Site'  -filter "system.webServer/rewrite/rules/rule[@name='ConvertedRule']/match" -name "url" -value "^(.*)$"
Set-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST/Default Web Site'  -filter "system.webServer/rewrite/rules/rule[@name='ConvertedRule']/match" -name "ignoreCase" -value "False"

Add-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST/Default Web Site'  -filter "system.webServer/rewrite/rules/rule[@name='ConvertedRule']/conditions" -name "." -value @{input='{REQUEST_FILENAME}';matchType='IsFile';negate='True'}

Add-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST/Default Web Site'  -filter "system.webServer/rewrite/rules/rule[@name='ConvertedRule']/conditions" -name "." -value @{input='{REQUEST_FILENAME}';matchType='IsDirectory';negate='True'}
Set-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST/Default Web Site'  -filter "system.webServer/rewrite/rules/rule[@name='ConvertedRule']/action" -name "type" -value "Rewrite"
Set-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST/Default Web Site'  -filter "system.webServer/rewrite/rules/rule[@name='ConvertedRule']/action" -name "url" -value "/cms/index.php?/{R:1}"
Set-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST/Default Web Site'  -filter "system.webServer/rewrite/rules/rule[@name='ConvertedRule']/action" -name "appendQueryString" -value "False"

and will produce configuration that looks as follows:

<rule name="ConvertedRule" stopProcessing="true">
   <match url="^(.*)$" ignoreCase="false" />
   <conditions>
      <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
      <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
   </conditions>
   <action type="Rewrite" url="/cms/index.php?/{R:1}" appendQueryString="false" />
</rule>


Answered By - Rich-Lang
Answer Checked By - Cary Denson (PHPFixing Admin)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Sunday, October 23, 2022

[FIXED] How to send class equals implementation to client using a WCF Web Server

 October 23, 2022     c#, datamember, java-client, wcf, webserver     No comments   

Issue

I'm developing an aplication in java (JSF) which communicates whith an WCF web server. I developed the webserver using c#, and I'm havin trouble to send the equals implementation of an complex object to the java client. For example, consider this c# class:

[DataContract(Namespace = "http://mywebservice.com/Entidades")]
    public class Record{private Int64 id;
    [DataMember]
    public Int64 Id
    {
        get { return id; }
        set { id = value; }
    }

    public override bool Equals(Object obj)
    {
          if(obj is Record){
               Record rec = obj as Record;
               return rec.Id == this.Id;
         }
         return false;
    }

}

First tryed to put the [DataMember] in the equals, but I discovered that I can't do that. How is the right way to send this implementation of the "equals" of this complex type to the java client?

Thanks in advance


Solution

That doesn't make sense.
Web services transfer data, not code.

You need to implement equals() in you Java objects in source.



Answered By - SLaks
Answer Checked By - Gilberto Lyons (PHPFixing Admin)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Wednesday, September 21, 2022

[FIXED] How to serve other vhosts next to Gitlab Omnibus server? [Full step-by-step solution]

 September 21, 2022     gitlab, gitlab-omnibus, nginx, virtualhost, webserver     No comments   

Issue

I installed Gitlab CE on a dedicated Ubuntu 14.04 server edition with Omnibus package.

Now I would want to install three other virtual hosts next to gitlab.

Two are node.js web applications launched by a non-root user running on two distinct ports > 1024, the third is a PHP web application that need a web server to be launched from.

There are:

  • a private bower registry running on 8081 (node.js)
  • a private npm registry running on 8082 (node.js)
  • a private composer registry (PHP)

But Omnibus listen 80 and doesn't seem to use neither Apache2 or Nginx, thus I can't use them to serve my PHP app and reverse-proxy my two other node apps.

What serving mechanics Gitlab Omnibus uses to listen 80 ? How should I create the three other virtual hosts to be able to provide the following vHosts ?

  • gitlab.mycompany.com (:80) -- already in use
  • bower.mycompany.com (:80)
  • npm.mycompany.com (:80)
  • packagist.mycompany.com (:80)

Solution

About these

But Omnibus listen 80 and doesn't seem to use neither Apache2 or Nginx [, thus ...].

and @stdob comment :

Did omnibus not use nginx as a web server ??? –

Wich I responded

I guess not because nginx package isn't installed in the system ...

In facts

From Gitlab official docs :

By default, omnibus-gitlab installs GitLab with bundled Nginx.

So yes!

Omnibus package actually uses Nginx !

but it was bundled, explaining why it doesn't require to be installed as dependency from the host OS.

Thus YES! Nginx can, and should be used to serve my PHP app and reverse-proxy my two other node apps.

Then now

Omnibus-gitlab allows webserver access through user gitlab-www which resides in the group with the same name. To allow an external webserver access to GitLab, external webserver user needs to be added gitlab-www group.

To use another web server like Apache or an existing Nginx installation you will have to do the following steps:

Disable bundled Nginx by specifying in /etc/gitlab/gitlab.rb

nginx['enable'] = false
# For GitLab CI, use the following:
ci_nginx['enable'] = false

Check the username of the non-bundled web-server user. By default, omnibus-gitlab has no default setting for external webserver user. You have to specify the external webserver user username in the configuration! Let's say for example that webserver user is www-data. In /etc/gitlab/gitlab.rb set

web_server['external_users'] = ['www-data']

This setting is an array so you can specify more than one user to be added to gitlab-www group.

Run sudo gitlab-ctl reconfigure for the change to take effect.

Setting the NGINX listen address or addresses

By default NGINX will accept incoming connections on all local IPv4 addresses. You can change the list of addresses in /etc/gitlab/gitlab.rb.

nginx['listen_addresses'] = ["0.0.0.0", "[::]"] # listen on all IPv4 and IPv6 addresses

For GitLab CI, use the ci_nginx['listen_addresses'] setting.

Setting the NGINX listen port

By default NGINX will listen on the port specified in external_url or implicitly use the right port (80 for HTTP, 443 for HTTPS). If you are running GitLab behind a reverse proxy, you may want to override the listen port to something else. For example, to use port 8080:

nginx['listen_port'] = 8080

Similarly, for GitLab CI:

ci_nginx['listen_port'] = 8081

Supporting proxied SSL

By default NGINX will auto-detect whether to use SSL if external_url contains https://. If you are running GitLab behind a reverse proxy, you may wish to keep the external_url as an HTTPS address but communicate with the GitLab NGINX internally over HTTP. To do this, you can disable HTTPS using the listen_https option:

nginx['listen_https'] = false

Similarly, for GitLab CI:

ci_nginx['listen_https'] = false

Note that you may need to configure your reverse proxy to forward certain headers (e.g. Host, X-Forwarded-Ssl, X-Forwarded-For, X-Forwarded-Port) to GitLab.

You may see improper redirections or errors (e.g. "422 Unprocessable Entity", "Can't verify CSRF token authenticity") if you forget this step. For more information, see:

  • What's the de facto standard for a Reverse Proxy to tell the backend SSL is used?
  • https://wiki.apache.org/couchdb/Nginx_As_a_Reverse_Proxy

To go further you can follow the official docs at https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/doc/settings/nginx.md#using-a-non-bundled-web-server

Configuring our gitlab virtual host

Installing Phusion Passenger

We need to install ruby (gitlab run in omnibus with a bundled ruby) globally in the OS

$ sudo apt-get update 
$ sudo apt-get install ruby
$ sudo gem install passenger

Recompile nginx with the passenger module

Instead of Apache2 for example, nginx isn't able to be plugged with binary modules on-the-fly. It must be recompiled for each new plugin you want to add.

Phusion passenger developer team worked hard to provide saying, "a bundled nginx version of passenger" : nginx bins compiled with passenger plugin.

So, lets use it:

requirement: we need to open our TCP port 11371 (the APT key port).

$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 561F9B9CAC40B2F7
$ sudo apt-get install apt-transport-https ca-certificates
creating passenger.list
$ sudo nano /etc/apt/sources.list.d/passenger.list

with these lignes

# Ubuntu 14.04
deb https://oss-binaries.phusionpassenger.com/apt/passenger trusty main

use the right repo for your ubuntu version. For Ubuntu 15.04 for example: deb https://oss-binaries.phusionpassenger.com/apt/passenger vivid main

Edit permissions:

$ sudo chown root: /etc/apt/sources.list.d/passenger.list
$ sudo chmod 600 /etc/apt/sources.list.d/passenger.list

Updating package list:

$ sudo apt-get update

Allowing it as unattended-upgrades

$ sudo nano /etc/apt/apt.conf.d/50unattended-upgrades

Find or create this config block on top of the file:

// Automatically upgrade packages from these (origin:archive) pairs
Unattended-Upgrade::Allowed-Origins {

  // you may have some instructions here

};

Add the following:

// Automatically upgrade packages from these (origin:archive) pairs
Unattended-Upgrade::Allowed-Origins {

  // you may have some instructions here

  // To check "Origin:" and "Suite:", you could use e.g.:
  // grep "Origin\|Suite" /var/lib/apt/lists/oss-binaries.phusionpassenger.com*
    "Phusion:stable";

};

Now (re)install nginx-extra and passenger:

$ sudo cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.bak_"$(date +%Y-%m-%d_%H:%M)"
$ sudo apt-get install nginx-extras passenger

configure it

Uncomment the passenger_root and passenger_ruby directives in the /etc/nginx/nginx.conf file:

$ sudo nano /etc/nginx/nginx.conf

... to obtain something like:

##
# Phusion Passenger config
##
# Uncomment it if you installed passenger or passenger-enterprise
##

passenger_root /usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini;
passenger_ruby /usr/bin/passenger_free_ruby;

create the nginx site configuration (the virtual host conf)

$ nano /etc/nginx/sites-available/gitlab.conf

server {
  listen *:80;
  server_name gitlab.mycompany.com;
  server_tokens off;
  root /opt/gitlab/embedded/service/gitlab-rails/public;

  client_max_body_size 250m;
  access_log  /var/log/gitlab/nginx/gitlab_access.log;
  error_log   /var/log/gitlab/nginx/gitlab_error.log;

  # Ensure Passenger uses the bundled Ruby version
  passenger_ruby /opt/gitlab/embedded/bin/ruby;

  # Correct the $PATH variable to included packaged executables
  passenger_env_var PATH "/opt/gitlab/bin:/opt/gitlab/embedded/bin:/usr/local/bin:/usr/bin:/bin";

  # Make sure Passenger runs as the correct user and group to
  # prevent permission issues
  passenger_user git;
  passenger_group git;

  # Enable Passenger & keep at least one instance running at all times
  passenger_enabled on;
  passenger_min_instances 1;

  error_page 502 /502.html;
}

Now we can enable it:

$ sudo ln -s /etc/nginx/sites-available/gitlab.cong /etc/nginx/sites-enabled/

There is no a2ensite equivalent coming natively with nginx, so we use ln, but if you want, there is a project on github: nginx_ensite: nginx_ensite and nginx_dissite for quick virtual host enabling and disabling

This is a shell (Bash) script that replicates for nginx the Debian a2ensite and a2dissite for enabling and disabling sites as virtual hosts in Apache 2.2/2.4.

It' done :-). Finally, restart nginx

$ sudo service nginx restart

With this new configuration, you are able to run other virtual hosts next to gitlab to serve what you want

Just create new configs in /etc/nginx/sites-available.

In my case, I made running and serving this way on the same host :

  • gitlab.mycompany.com - the awesome git platform written in ruby
  • ci.mycompany.com - the gitlab continuous integration server written in ruby
  • npm.mycompany.com - a private npm registry written in node.js
  • bower.mycompany.com - a private bower registry written in node.js
  • packagist.mycompany.com - a private packagist for composer registry written in php

For example, to serve npm.mycompany.com :

Create a directory for logs:

$ sudo mkdir -p /var/log/private-npm/nginx/

And fill a new vhost config file:

$ sudo nano /etc/nginx/sites-available/npm.conf

With this config

server {
  listen *:80;
  server_name npm.mycompany.com

  client_max_body_size 5m;
  access_log  /var/log/private-npm/nginx/npm_access.log;
  error_log   /var/log/private-npm/nginx/npm_error.log;

  location / {
    proxy_pass http://localhost:8082;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection 'upgrade';
    proxy_set_header Host $host;
    proxy_cache_bypass $http_upgrade;
  }
}

Then enable it and restart it:

$ sudo ln -s /etc/nginx/sites-available/npm.conf /etc/nginx/sites-enabled/
$ sudo service nginx restart


Answered By - Rémi Becheras
Answer Checked By - Clifford M. (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

[FIXED] Why does this config always shows my default web server?

 September 21, 2022     apache, debugging, virtualhost, web, webserver     No comments   

Issue

I have the attached config, I am trying to display mysite.com (defined as vhost at the very end) but it always shows the default index page, the one I have in /var/www/html/domains/default/index.php

I know one cause can be wrong permission code on my vhost folder, but I don't think that is the case now, I don't see that common forbidden error in logs and for debugging purposes I set the full path of sub-directories to belong to apache:apache

I also tried to move my vhost at the top of the .conf but it made no difference.

ServerRoot "/etc/httpd"


Listen *:80
Listen *:443

Include conf.modules.d/*.conf


User apache
Group apache


ServerAdmin root@localhost


ServerName vm3.mysite.com:80

<Directory />
    AllowOverride all
    Require all granted
</Directory>



DocumentRoot "/var/www/html/domains/default"

<Directory "/var/www">
    AllowOverride All
    Require all granted
</Directory>

<Directory "/var/www/html">
    Options Indexes FollowSymLinks


    AllowOverride All

    Require all granted
</Directory>

<IfModule dir_module>
    DirectoryIndex index.html
</IfModule>

<Files ".ht*">
    Require all denied
</Files>

ErrorLog "logs/error_log"

LogLevel warn

<IfModule log_config_module>
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%h %l %u %t \"%r\" %>s %b" common

    <IfModule logio_module>
      LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
    </IfModule>

    CustomLog "logs/access_log" combined
</IfModule>

<IfModule alias_module>

    ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"

</IfModule>

<Directory "/var/www/cgi-bin">
    AllowOverride None
    Options None
    Require all granted
</Directory>

<IfModule mime_module>
    TypesConfig /etc/mime.types

    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz

    AddType text/html .shtml
    AddOutputFilter INCLUDES .shtml
</IfModule>

AddDefaultCharset UTF-8

<IfModule mime_magic_module>
    MIMEMagicFile conf/magic
</IfModule>


EnableSendfile on

IncludeOptional conf.d/*.conf


<VirtualHost mysite.com:80>
        DocumentRoot /var/www/html/domains/mysite.com
        ServerName mysite.com
        <Directory "/var/www/html/domains/mysite.com">
                allow from all
                Options None
                Require all granted
        </Directory>
</VirtualHost>


KeepAlive on

Solution

You have vm3.mysite.com configured outside of a VirtualHost block, which apache is using unconditionally and ignoring the mysite.com vhost. You could fix this by moving vm3.mysite.com into a separate vhost (where they occur in the config file doesn't really matter, so long as they're both in a vhost).

Here is your config, with some of the directives reorganized for clarity, and the relevant bits moved into a proper VirtualHost block at the bottom:

ServerRoot "/etc/httpd"

Listen *:80
Listen *:443

User apache
Group apache

KeepAlive on
EnableSendfile on
Include conf.modules.d/*.conf
IncludeOptional conf.d/*.conf

<Directory "/var/www">
    AllowOverride All
    Require all granted
</Directory>

<Directory "/var/www/html">
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>

<IfModule dir_module>
    DirectoryIndex index.html
</IfModule>

<Files ".ht*">
    Require all denied
</Files>

ErrorLog "logs/error_log"

LogLevel warn

<IfModule log_config_module>
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%h %l %u %t \"%r\" %>s %b" common
    <IfModule logio_module>
        LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
    </IfModule>
    CustomLog "logs/access_log" combined
</IfModule>

<IfModule alias_module>
    ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
</IfModule>

<Directory "/var/www/cgi-bin">
    AllowOverride None
    Options None
    Require all granted
</Directory>

<IfModule mime_module>
    TypesConfig /etc/mime.types
    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz
    AddType text/html .shtml
    AddOutputFilter INCLUDES .shtml
</IfModule>

AddDefaultCharset UTF-8

<IfModule mime_magic_module>
    MIMEMagicFile conf/magic
</IfModule>

<VirtualHost vm3.mysite.com:80>
    ServerAdmin root@localhost
    ServerName vm3.mysite.com
    DocumentRoot "/var/www/html/domains/default"
    <Directory />
        AllowOverride all
        Require all granted
    </Directory>
</VirtualHost>

<VirtualHost mysite.com:80>
    DocumentRoot /var/www/html/domains/mysite.com
    ServerName mysite.com
    <Directory "/var/www/html/domains/mysite.com">
        allow from all
        Options None
        Require all granted
    </Directory>
</VirtualHost>

To keep things better organized, you might consider moving those vhosts to a separate config file under conf.d/<your_file>.conf which will be included in the main config automatically. This would allow you to keep your vhost settings separate from the general server config and avoid most of the previous confusion.



Answered By - AfroThundr
Answer Checked By - Pedro (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Sunday, September 18, 2022

[FIXED] what is meant by extension and binary file of a library?

 September 18, 2022     imagick, php, python-imaging-library, webserver     No comments   

Issue

This is more of a general question but for reference, I read statements like: "Most of the shared hosting providers do not compile imagick extension with PHP, but imagick binaries will be available". I don't know what is meant by "imagick extension" and "imagick binaries"? To me, any non-txt file is a binary. Also, when we install a library like "imagick", are both these kinds of version installed? And what is the difference between them?


Solution

"Imagick extension" is the optional component of PHP that adds Imagick-related functions to the language.

"binaries" means programs that are compiled to machine code, as opposed to source code or scripts.

So they're saying that you won't be able to use the built-in Imagic functions in PHP, but you could execute the external programs using methods like shell_exec().



Answered By - Barmar
Answer Checked By - Timothy Miller (PHPFixing Admin)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Thursday, September 1, 2022

[FIXED] How to block port server from http request

 September 01, 2022     docker, linux, nginx-reverse-proxy, server, webserver     No comments   

Issue

I have Nginx has a reversed proxy to connect client request to docker running container. The problem is you can access container by typing serverhost.fr:port_number. I want the client to only access the running container by a specific hostname. Here my docker-compose.yml file :

version: '3'
services:
    api:
        image: username/backendimgage:latest
        ports:
            - "8081:8000"
        restart: always
    front:
        depends_on:
            - api
        image: username/frontendimage:latest
        ports:
            - "8080:36073"
        restart: always

I've tried to block with ufw, it breaks everything. I've tried to send a 401 code on Nginx using if statement like

if ( $host = serverhost.fr:port_number ){ return 401; } 

OR

if ( $host ~* portnumber ){ return 401; }

But it doesn't work. I don't have a big ops background so I'm kind of lost.


Solution

If you're running the nginx proxy outside of Docker, you must connect to the published ports: from your containers.

By default when you publish ports: they're published on all interfaces of the host system. However, you can specify an alternate bind address. If you set a backend service to only publish on the 127.0.0.1 localhost interface, it won't be reachable from off host.

version: '3'
services:
    api:
        image: username/backendimgage:latest
        ports:
            - "127.0.0.1:8081:8000"
            #  ^^^^^^^^^

(If you're trying to connect from one container to another by using its host port – something like http://host.docker.internal:8081 on MacOS/Windows platforms – this will interfere with that, but you should be able to use Docker-native inter-container communication there.)



Answered By - David Maze
Answer Checked By - Senaida (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Wednesday, August 24, 2022

[FIXED] How to install Gin with Golang

 August 24, 2022     go, go-gin, linux, module, webserver     No comments   

Issue

I'm a newbie on Golang, and I'm trying to use Gin to develop a web server on Ubuntu 16.04.

After executing go get -u github.com/gin-gonic/gin, many folders appear at ~/go/pkg/mod/github.com/.

Then I try to make an example:

package main

import "github.com/gin-gonic/gin"

func main() {
    r := gin.Default()
    r.GET("/ping", func(c *gin.Context) {
        c.JSON(200, gin.H{
            "message": "pong",
        })
    })
    r.Run() // listen and serve on 0.0.0.0:8080 (for windows "localhost:8080")
}

However, go run example.go made the error:

example.go:3:8: cannot find package "github.com/gin-gonic/gin" in any of:
        /usr/local/go/src/github.com/gin-gonic/gin (from $GOROOT)
        /home/zyh/go/src/github.com/gin-gonic/gin (from $GOPATH)

In my system, $GOROOT is /usr/local/go/ and $GOPATH is ~/go/.

How could I solve this problem?


Solution

For Go version 1.11 or newer, You should use Go Modules.

If you are just starting with Go, you should start with the newer version. I think you are using a Go version that supports go modules already because the modules you are trying to get are downloading to ~/go/pkg/mod/ directory.

To initialize a project with go module, run:

go mod init your-project-name

This will create a go.mod file in your project directory.

Add missing and/or remove unused modules:

go mod tidy

This will fill up the go.mod file with appropriate modules and create a go.sum in your project directory. The go.sum contains expected cryptographic hashes of each module version.

After that, the go run example.go command should run the program without any issues.


You can even vendor the modules in your project directory:

go mod vendor

This will bring all the vendors to your projects /vendor directory so that you don't need to get the modules again if working from another machine on this project.



Answered By - aniskhan001
Answer Checked By - Gilberto Lyons (PHPFixing Admin)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Monday, August 1, 2022

[FIXED] How to setup PHP server in production?

 August 01, 2022     php, port, ssh, vps, webserver     No comments   

Issue

I use php -S 127.0.0.1:4242 command to start development server on localhost for php files. But I guess, I shouldn't use this thing in production. Currently I'm trying to setup my website on VPS and I don't know how to start php server forever using ssh on port 4242. I know, this is probably very dumb question, this is my first time I work with real hosting

Would be grateful to any help :)


Solution

You need to setup virtual host so that it should run always.

Here is a full doc of setup guide on server.



Answered By - dev_mustafa
Answer Checked By - Cary Denson (PHPFixing Admin)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Sunday, July 3, 2022

[FIXED] how to configuring a xampp web server for different root directory

 July 03, 2022     apache, php, webserver, xampp     No comments   

Issue

The web directory is the home of all of your application's public and static files. Including images, stylesheets and JavaScript files. It is also where the front controllers live.

So the question is when i install and set up xampp my web directory is:

xampp\htdocs

and I want to set it up for:

xampp\htdocs\myproject\web

How to do it? Now when I type in my browser the address: http://localhost/
I enter xampp\htdocs directory
and I want to type in my browser the address: http://localhost/
and enter xampp\htdocs\myproject\web directory


Solution

You can change Apaches httpd.conf by clicking (in xampp control panel) apache/conf/httpd.conf and adjust the entries for DocumentRoot and the corresponding Directory entry. Just Ctrl+F for "htdocs" and change the entries to your new path.

See screenshot:

XAMPP config

#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "C:/xampp/htdocs"
<Directory "C:/xampp/htdocs">


Answered By - blckwngd
Answer Checked By - Willingham (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Friday, June 24, 2022

[FIXED] What is the difference between reverse proxy and web server?

 June 24, 2022     apache, appserver, reverse-proxy, terminology, webserver     No comments   

Issue

I read an awesome post on application server vs. webserver at What is the difference between application server and web server?. Moreover, Difference between proxy server and reverse proxy server nicely explains what a proxy server is.

I also learned that some web servers, such as Apache, have reverse proxy built-in. (Source). Also, Wikipedia (https://en.wikipedia.org/wiki/Reverse_proxy) has an image that shows webserver and reverse proxy as separate entities.

enter image description here

Source: https://en.wikipedia.org/wiki/Reverse_proxy (image originally via Privacy Canada, now CC0, license info)

So, I am not sure about the difference between webserver and reverse proxy. Can someone please shed the light?


Solution

A web server listens for HTTP requests and reacts to them by sending back an HTTP response.

A reverse proxy is a web server which determines what response to make by also implementing an HTTP client.

Client A makes an HTTP request to the reverse proxy. The reverse proxy makes an HTTP request to Server B. Server B sends an HTTP response to the reverse proxy. The reverse proxy sends that data as its HTTP response to client A.



Answered By - Quentin
Answer Checked By - Terry (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Thursday, May 19, 2022

[FIXED] What are the benefits of using Nginx in front of a webserver for Go?

 May 19, 2022     go, http, nginx, web-services, webserver     No comments   

Issue

I am writing some webservices returning JSON data, which have lots of users.

What are the benefits of using Nginx in front my server compared to just using the go http server?


Solution

It depends.

Out of the box, putting nginx in front as a reverse proxy is going to give you:

  • Access logs
  • Error logs
  • Easy SSL termination
  • SPDY support
  • gzip support
  • Easy ways to set HTTP headers for certain routes in a couple of lines
  • Very fast static asset serving (if you're serving off S3/etc. though, this isn't that relevant)

The Go HTTP server is very good, but you will need to reinvent the wheel to do some of these things (which is fine: it's not meant to be everything to everyone).

I've always found it easier to put nginx in front—which is what it is good at—and let it do the "web server" stuff. My Go application does the application stuff, and only the bare minimum of headers/etc. that it needs to. Don't look at putting nginx in front as a "bad" thing.



Answered By - elithrar
Answer Checked By - Mildred Charles (PHPFixing Admin)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

[FIXED] How to check the version compatibility of an exe?

 May 19, 2022     c#, visual-studio-2008, web-services, webserver, windows     No comments   

Issue

How to compare the version of an application in server and the application installed in client machine?


Solution

There are many ways.

  1. Server can have a public WCF service, that returns the version of the app on the server. It can take it from exe file that is lying on the server (using reflection), or just parsing some server xml file - that can be updated by deployment responsible person. You can consume that service in your client app when needed.

  2. ClickOnce deployment gives you abbility not to think about versioning. You can configure such deployment in a way that application won't start if there is a new version on server(that will be downloaded automatically).

Others are variations of connection to the server method and deployment configuration. Choose what fits you most.

Don't forget to mark this as correct in case it fits you.



Answered By - Sasha Reminnyi
Answer Checked By - Senaida (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Thursday, April 21, 2022

[FIXED] how to change the localhost to machine name?

 April 21, 2022     connection, localhost, mantis, mysql, webserver     No comments   

Issue

I am running a webserver for Mantis BT. I have configured it on my laptop for test phase. The user's which I have created manually receive a URL for initial sign-up. they can only connect to me by replacing the localhost in the URL with my laptop name. is there any way to replace the localhost with my machine name in MySQL?


Solution

Set g_path in config_inc.php. For example:

$g_path = "http://my-hostname/demo/mantis";


Answered By - libregeek
Answer Checked By - Timothy Miller (PHPFixing Admin)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Tuesday, March 15, 2022

[FIXED] Default permission when creating a folder

 March 15, 2022     apache, lamp, permissions, webserver     No comments   

Issue

I am trying to use umask to create default permission to directories that I create but it does not work. I want files created in FTP have automatically permission 777 (my server is running LAMP on CENTOS).

I tried umask 000 but always I create a folder it has permission 666 not 777.

How can I fix this?


Solution

If it is vsftpd, see if you have file_open_mode setting in vsftpd.conf. man vsftpd.conf says

file_open_mode
The permissions with which uploaded files are created. Umasks are applied on top of 
this value. You may wish to change to 0777 if you want uploaded files to be executable.
Default: 0666

(Ref: https://security.appspot.com/vsftpd/vsftpd_conf.html)



Answered By - nohup
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Saturday, March 12, 2022

[FIXED] Malformed MIME header error in Symfony 5.3

 March 12, 2022     mime, php, postgresql, symfony, webserver     No comments   

Issue

I'm working on a project with Symfony 5.3 with PHP 8.0.12. I've been developing it on my own computer, it's working well. I now want to deploy it on a remote container.

However when I start the Symfony built in Webserver I'm getting the following error when accessing any of the defined routes:

issue with server callback error="unable to fetch the response from the backend: malformed MIME header: missing colon: "FROM information_schema.schemata""

In both cases (on my computer and in the container), the server is connecting to a remote PostgreSQL database. The container doesn't seem to have any problem connecting to the database though, as I can manually connect using the psql command.

I've tried reinstalling Symfony (Symfony CLI version v4.26.8), Composer (version 2.1.12), and most PHP libraries but that didn't change anything.

I have no idea where the problem is. Any help would be greatly appreciated.

Here is my composer.json:

{
"type": "project",
"license": "proprietary",
"minimum-stability": "stable",
"prefer-stable": true,
"require": {
    "php": ">=7.2.5",
    "ext-ctype": "*",
    "ext-iconv": "*",
    "ext-json": "*",
    "composer/package-versions-deprecated": "1.11.99.2",
    "doctrine/annotations": "^1.13",
    "doctrine/doctrine-bundle": "^2.4",
    "doctrine/doctrine-migrations-bundle": "^3.1",
    "doctrine/orm": "^2.9",
    "lexik/jwt-authentication-bundle": "^2.13",
    "sensio/framework-extra-bundle": "^6.2",
    "symfony/apache-pack": "^1.0",
    "symfony/dotenv": "5.3.*",
    "symfony/flex": "^1.15",
    "symfony/framework-bundle": "5.3.*",
    "symfony/http-foundation": "5.3.*",
    "symfony/ldap": "5.3.*",
    "symfony/proxy-manager-bridge": "5.3.*",
    "symfony/security-bundle": "5.3.*",
    "symfony/stopwatch": "5.3.*",
    "symfony/web-profiler-bundle": "5.3.*",
    "symfony/property-access": "5.3.*",
    "symfony/runtime": "5.3.*",
    "symfony/security-csrf": "5.3.*",
    "symfony/serializer": "5.3.*",
    "symfony/yaml": "5.3.*"
},
"config": {
    "optimize-autoloader": true,
    "preferred-install": {
        "*": "dist"
    },
    "sort-packages": true
},
"autoload": {
    "psr-4": {
        "App\\": "src/"
    }
},
"autoload-dev": {
    "psr-4": {
        "App\\Tests\\": "tests/"
    }
},
"replace": {
    "symfony/polyfill-ctype": "*",
    "symfony/polyfill-iconv": "*",
    "symfony/polyfill-php72": "*"
},
"scripts": {
    "auto-scripts": {
        "cache:clear": "symfony-cmd",
        "assets:install %PUBLIC_DIR%": "symfony-cmd"
    },
    "post-install-cmd": [
        "@auto-scripts"
    ],
    "post-update-cmd": [
        "@auto-scripts"
    ]
},
"conflict": {
    "symfony/symfony": "*"
},
"extra": {
    "symfony": {
        "allow-contrib": false,
        "require": "5.3.*"
    }
},
"require-dev": {
    "symfony/maker-bundle": "^1.33"
}
}

Solution

I have had this error when using symfony server:start with docker inside a php-alpine container. Each time i run migrations or doctrine:schema:update in a fresh installed instance, my symfony local web-server would throw error: issue with server callback error="unable to fetch the response from the backend: malformed MIME header: missing colon: "FROM information_schema.schemata I solved it by dropping the alpine container and building everything from the FROM ubuntu:20.04 image: i had to install php, drivers and all dependencies too. This did not go well with my production env because the image was above 1GB, meaning it had binaries i did not need in production. From experience the symfony local web-server needs a python environment but am not sure on that.

After some days, i stumbled on this git repository: https://github.com/dunglas/symfony-docker. which is recommended from Symfony docs here: Using Docker with Symfony. It uses caddy as the web-server. I learnt from it, tweaked to suit my needs and from then never used symfony local web-server. Its a good project, kudos to Kévin Dunglas and maintainers. The php image is about 200MB. Caddy too is about 40MB. Great for both prod and dev environments.

Please peruse the repo and adopt what you can or everything.

Disclaimer: This is not an answer to your problem/error, but an easy alternative.



Answered By - Ngatia Frankline
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Friday, February 11, 2022

[FIXED] Set up htaccess so that everyone is denied except one IP, BUT it requires authenticaion

 February 11, 2022     .htaccess, apache, lamp, linux, webserver     No comments   

Issue

I want to set up .htaccess on my Apache web server such that all users are straight-up denied access except one user which is my IP. Since this IP represents my entire home network, I also want to add authentication in the case the IP is correct to ensure that only I can access that directory and no one else using my home network.

This is how my .htaccess file looks so far:

Order deny,allow
Deny from all
AuthType Basic
AuthUserFile /var/www/path_to_forbiden_dir/.htpasswd
AuthName "Protected"
require valid-user
Allow from xxx.xx.xx.xxx

where xxx.xx.xx.xxx is my IP

This works in denying IPs outside the local network, however no authentication is shown when I try to access that directory from the IP specified. So, how can I create authentication only for the IP specified?


Solution

Thanks, but I resolved the issue by following the instructions on https://help.ubuntu.com/community/EnablingUseOfApacheHtaccessFiles I had forgotten to set up Directory override of htpasswd in apache2.conf



Answered By - hesson
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Wednesday, February 9, 2022

[FIXED] Forward two different websites to the same server

 February 09, 2022     debian, dns, forwarding, lamp, webserver     No comments   

Issue

I'm pretty new in webserver management. So I rented this server, and setup a LAMP server with MySql and everything is alright in that sense.

The problem is now that I have two different domains (say www.domain1.com, www.domain2.org), and I want each of them to load the website content from a different folder on my server.

How can I do that?

I tried to google some relevant terms, but I couldn't find what that's called.

Thank you for any efforts.


Solution

If you use Apache2, you can use the ServerName directive in the VirtualHost configuration:

<VirtualHost *:80>
    ServerName www.domain1.com
    DocumentRoot /folder1
</VirtualHost>

<VirtualHost *:80>
    ServerName www.domain2.com
    DocumentRoot /folder2
</VirtualHost>


Answered By - atenart
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Monday, February 7, 2022

[FIXED] What is the easiest way to have a local LAMP installation for web development on mac OS X?

 February 07, 2022     lamp, macos, webserver     No comments   

Issue

I'm new to mac os x. In the Windows XP world, there are packages available, like easyPHP, wampserver, uniformserver, that enable you to have a local webserver complete with php, mysql configured via an automatic installer. Really handy.

I need the same on my new mac. I know mac os x comes with a local webserver. Is this already with php, mysql preinstalled?

I'd like to have you guys advise on the easiest way to have this local lamp so that i can continue developing on this nice and shiny machine.

thanks!


Solution

Question : What means LAMP ?

Answer : Linux Apache MySQL PHP

Q: and if this was running on a Mac ?

A : try MAMP



Answered By - chburd
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Older Posts Home

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
All Comments
Atom
All Comments

Copyright © PHPFixing